MatchAttribute.MaxRepeats Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets the maximum number of values to return from the match.
public:
property int MaxRepeats { int get(); void set(int value); };
public int MaxRepeats { get; set; }
member this.MaxRepeats : int with get, set
Public Property MaxRepeats As Integer
Property Value
The maximum number of values to return from the match. The default value is -1, which refers to returning all values.
Examples
public ref class Example_Headers
{
public:
[MatchAttribute("TITLE>(.*?)<")]
String^ Title;
[MatchAttribute("",Pattern="h1>(.*?)<",IgnoreCase=true)]
String^ H1;
[MatchAttribute("H2>((([^<,]*),?)+)<",Group=3,Capture=4)]
String^ Element;
[MatchAttribute("H2>((([^<,]*),?){2,})<",Group=3,MaxRepeats=0)]
array<String^>^ Elements1;
[MatchAttribute("H2>((([^<,]*),?){2,})<",Group=3,MaxRepeats=1)]
array<String^>^ Elements2;
[MatchAttribute("H3 ([^=]*)=([^>]*)",Group=1)]
String^ Attribute;
[MatchAttribute("H3 ([^=]*)=([^>]*)",Group=2)]
String^ Value;
};
public class Example_Headers
{
[MatchAttribute("TITLE>(.*?)<")]
public string Title;
[MatchAttribute("", Pattern="h1>(.*?)<", IgnoreCase=true)]
public string H1;
[MatchAttribute("H2>((([^<,]*),?)+)<", Group=3, Capture=4)]
public string Element;
[MatchAttribute("H2>((([^<,]*),?){2,})<", Group=3, MaxRepeats=0)]
public string[] Elements1;
[MatchAttribute("H2>((([^<,]*),?){2,})<", Group=3, MaxRepeats=1)]
public string[] Elements2;
[MatchAttribute("H3 ([^=]*)=([^>]*)", Group=1)]
public string Attribute;
[MatchAttribute("H3 ([^=]*)=([^>]*)", Group=2)]
public string Value;
}
Public Class Headers
<MatchAttribute("TITLE>(.*?)<")> _
Public Title As String
<MatchAttribute("", Pattern:="h1>(.*?)<", IgnoreCase:=True)> _
Public H1 As String
<MatchAttribute("H2>((([^<,]*),?)+)<", Group:=3, Capture:=4)> _
Public Element As String
<MatchAttribute("H2>((([^<,]*),?){2,})<", Group:=3, MaxRepeats:=0)> _
Public Elements1() As String
<MatchAttribute("H2>((([^<,]*),?){2,})<", Group:=3, MaxRepeats:=1)> _
Public Elements2() As String
<MatchAttribute("H3 ([^=]*)=([^>]*)", Group:=1)> _
Public Attribute As String
<MatchAttribute("H3 ([^=]*)=([^>]*)", Group:=2)> _
Public Value As String
End Class
Remarks
A value of 1 returns only the first match. A value of -1 returns all matches. Additionally, a value of -1 equates to an '*' in a regular expression.
Applies to
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.