MatchAttribute.MaxRepeats Proprietà

Definizione

Ottiene o imposta il numero massimo di valori che la corrispondenza deve restituire.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

Valore della proprietà

Numero massimo di valori che la corrispondenza deve restituire.The maximum number of values to return from the match. Il valore predefinito è -1, che rappresenta la restituzione di tutti i valori.The default value is -1, which refers to returning all values.

Esempi

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

Commenti

Un valore di 1 consente di restituire solo la prima corrispondenza.A value of 1 returns only the first match. Un valore di -1 consente invece di restituire tutte le corrispondenze.A value of -1 returns all matches. Inoltre, un valore pari a-1 equivale a' *' in un'espressione regolare.Additionally, a value of -1 equates to an '*' in a regular expression.

Si applica a