Regex.Count 方法

定義

多載

Count(String, String, RegexOptions, TimeSpan)

搜尋輸入字串中所有出現的正則運算式,並傳回相符專案的數目。

Count(ReadOnlySpan<Char>, String, RegexOptions, TimeSpan)

搜尋輸入範圍中所有出現的正則運算式,並傳回相符專案的數目。

Count(ReadOnlySpan<Char>, String, RegexOptions)

搜尋輸入範圍中所有出現的正則運算式,並傳回相符專案的數目。

Count(String, String)

搜尋輸入字串中所有出現的正則運算式,並傳回相符專案的數目。

Count(String, String, RegexOptions)

搜尋輸入字串中所有出現的正則運算式,並傳回相符專案的數目。

Count(ReadOnlySpan<Char>, Int32)

搜尋輸入範圍中所有出現的正則運算式,並傳回相符專案的數目。

Count(ReadOnlySpan<Char>, String)

搜尋輸入範圍中所有出現的正則運算式,並傳回相符專案的數目。

Count(String)

搜尋輸入字串中所有出現的正則運算式,並傳回相符專案的數目。

Count(ReadOnlySpan<Char>)

搜尋輸入範圍中所有出現的正則運算式,並傳回相符專案的數目。

Count(String, String, RegexOptions, TimeSpan)

搜尋輸入字串中所有出現的正則運算式,並傳回相符專案的數目。

public:
 static int Count(System::String ^ input, System::String ^ pattern, System::Text::RegularExpressions::RegexOptions options, TimeSpan matchTimeout);
public static int Count (string input, string pattern, System.Text.RegularExpressions.RegexOptions options, TimeSpan matchTimeout);
static member Count : string * string * System.Text.RegularExpressions.RegexOptions * TimeSpan -> int
Public Shared Function Count (input As String, pattern As String, options As RegexOptions, matchTimeout As TimeSpan) As Integer

參數

input
String

用來搜尋比對的字串。

pattern
String

要比對的規則運算式模式。

options
RegexOptions

列舉值的位元組合,這些值會指定用於比對的選項。

matchTimeout
TimeSpan

逾時間隔,若要表示此方法不應逾時則為 InfiniteMatchTimeout

傳回

符合項的數目。

例外狀況

inputpatternnull

options 不是 RegexOptions 值的有效位組合,或 matchTimeout 為負數、零或大於大約 24 天。

發生規則運算式剖析錯誤。

適用於

Count(ReadOnlySpan<Char>, String, RegexOptions, TimeSpan)

搜尋輸入範圍中所有出現的正則運算式,並傳回相符專案的數目。

public:
 static int Count(ReadOnlySpan<char> input, System::String ^ pattern, System::Text::RegularExpressions::RegexOptions options, TimeSpan matchTimeout);
public static int Count (ReadOnlySpan<char> input, string pattern, System.Text.RegularExpressions.RegexOptions options, TimeSpan matchTimeout);
static member Count : ReadOnlySpan<char> * string * System.Text.RegularExpressions.RegexOptions * TimeSpan -> int
Public Shared Function Count (input As ReadOnlySpan(Of Char), pattern As String, options As RegexOptions, matchTimeout As TimeSpan) As Integer

參數

input
ReadOnlySpan<Char>

要搜尋相符專案範圍。

pattern
String

要比對的規則運算式模式。

options
RegexOptions

列舉值的位元組合,這些值會指定用於比對的選項。

matchTimeout
TimeSpan

逾時間隔,若要表示此方法不應逾時則為 InfiniteMatchTimeout

傳回

符合項的數目。

例外狀況

options 不是值的有效位元組合 RegexOptions ,或 matchTimeout 為負數、零或大於大約 24 天。

發生規則運算式剖析錯誤。

適用於

Count(ReadOnlySpan<Char>, String, RegexOptions)

搜尋輸入範圍中所有出現的正則運算式,並傳回相符專案的數目。

public:
 static int Count(ReadOnlySpan<char> input, System::String ^ pattern, System::Text::RegularExpressions::RegexOptions options);
public static int Count (ReadOnlySpan<char> input, string pattern, System.Text.RegularExpressions.RegexOptions options);
static member Count : ReadOnlySpan<char> * string * System.Text.RegularExpressions.RegexOptions -> int
Public Shared Function Count (input As ReadOnlySpan(Of Char), pattern As String, options As RegexOptions) As Integer

參數

input
ReadOnlySpan<Char>

要搜尋相符專案範圍。

pattern
String

要比對的規則運算式模式。

options
RegexOptions

列舉值的位元組合,這些值會指定用於比對的選項。

傳回

符合項的數目。

例外狀況

options 不是 RegexOptions 值的有效位元組合。

發生規則運算式剖析錯誤。

適用於

Count(String, String)

搜尋輸入字串中所有出現的正則運算式,並傳回相符專案的數目。

public:
 static int Count(System::String ^ input, System::String ^ pattern);
public static int Count (string input, string pattern);
static member Count : string * string -> int
Public Shared Function Count (input As String, pattern As String) As Integer

參數

input
String

用來搜尋比對的字串。

pattern
String

要比對的規則運算式模式。

傳回

符合項的數目。

例外狀況

inputpatternnull

發生規則運算式剖析錯誤。

適用於

Count(String, String, RegexOptions)

搜尋輸入字串中所有出現的正則運算式,並傳回相符專案的數目。

public:
 static int Count(System::String ^ input, System::String ^ pattern, System::Text::RegularExpressions::RegexOptions options);
public static int Count (string input, string pattern, System.Text.RegularExpressions.RegexOptions options);
static member Count : string * string * System.Text.RegularExpressions.RegexOptions -> int
Public Shared Function Count (input As String, pattern As String, options As RegexOptions) As Integer

參數

input
String

用來搜尋比對的字串。

pattern
String

要比對的規則運算式模式。

options
RegexOptions

列舉值的位元組合,這些值會指定用於比對的選項。

傳回

符合項的數目。

例外狀況

inputpatternnull

options 不是 RegexOptions 值的有效位組合。

發生規則運算式剖析錯誤。

適用於

Count(ReadOnlySpan<Char>, Int32)

搜尋輸入範圍中所有出現的正則運算式,並傳回相符專案的數目。

public:
 int Count(ReadOnlySpan<char> input, int startat);
public int Count (ReadOnlySpan<char> input, int startat);
member this.Count : ReadOnlySpan<char> * int -> int
Public Function Count (input As ReadOnlySpan(Of Char), startat As Integer) As Integer

參數

input
ReadOnlySpan<Char>

要搜尋相符專案範圍。

startat
Int32

要開始搜尋之以零起始的字元位置。

傳回

符合項的數目。

適用於

Count(ReadOnlySpan<Char>, String)

搜尋輸入範圍中所有出現的正則運算式,並傳回相符專案的數目。

public:
 static int Count(ReadOnlySpan<char> input, System::String ^ pattern);
public static int Count (ReadOnlySpan<char> input, string pattern);
static member Count : ReadOnlySpan<char> * string -> int
Public Shared Function Count (input As ReadOnlySpan(Of Char), pattern As String) As Integer

參數

input
ReadOnlySpan<Char>

要搜尋相符專案範圍。

pattern
String

要比對的規則運算式模式。

傳回

符合項的數目。

例外狀況

發生規則運算式剖析錯誤。

適用於

Count(String)

搜尋輸入字串中所有出現的正則運算式,並傳回相符專案的數目。

public:
 int Count(System::String ^ input);
public int Count (string input);
member this.Count : string -> int
Public Function Count (input As String) As Integer

參數

input
String

用來搜尋比對的字串。

傳回

符合項的數目。

例外狀況

inputnull

適用於

Count(ReadOnlySpan<Char>)

搜尋輸入範圍中所有出現的正則運算式,並傳回相符專案的數目。

public:
 int Count(ReadOnlySpan<char> input);
public int Count (ReadOnlySpan<char> input);
member this.Count : ReadOnlySpan<char> -> int
Public Function Count (input As ReadOnlySpan(Of Char)) As Integer

參數

input
ReadOnlySpan<Char>

要搜尋相符專案範圍。

傳回

符合項的數目。

適用於