Regex.Count 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
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)
- Source:
- Regex.Count.cs
- Source:
- Regex.Count.cs
- Source:
- Regex.Count.cs
搜尋輸入字串中所有出現的正則運算式,並傳回相符專案的數目。
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。
傳回
符合項的數目。
例外狀況
input
或 pattern
為 null
。
options
不是 RegexOptions 值的有效位組合,或 matchTimeout
為負數、零或大於大約 24 天。
發生規則運算式剖析錯誤。
適用於
Count(ReadOnlySpan<Char>, String, RegexOptions, TimeSpan)
- Source:
- Regex.Count.cs
- Source:
- Regex.Count.cs
- Source:
- Regex.Count.cs
搜尋輸入範圍中所有出現的正則運算式,並傳回相符專案的數目。
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)
- Source:
- Regex.Count.cs
- Source:
- Regex.Count.cs
- Source:
- Regex.Count.cs
搜尋輸入範圍中所有出現的正則運算式,並傳回相符專案的數目。
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)
- Source:
- Regex.Count.cs
- Source:
- Regex.Count.cs
- Source:
- Regex.Count.cs
搜尋輸入字串中所有出現的正則運算式,並傳回相符專案的數目。
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
要比對的規則運算式模式。
傳回
符合項的數目。
例外狀況
input
或 pattern
為 null
。
發生規則運算式剖析錯誤。
適用於
Count(String, String, RegexOptions)
- Source:
- Regex.Count.cs
- Source:
- Regex.Count.cs
- Source:
- Regex.Count.cs
搜尋輸入字串中所有出現的正則運算式,並傳回相符專案的數目。
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
列舉值的位元組合,這些值會指定用於比對的選項。
傳回
符合項的數目。
例外狀況
input
或 pattern
為 null
。
options
不是 RegexOptions 值的有效位組合。
發生規則運算式剖析錯誤。
適用於
Count(ReadOnlySpan<Char>, Int32)
- Source:
- Regex.Count.cs
- Source:
- Regex.Count.cs
- Source:
- Regex.Count.cs
搜尋輸入範圍中所有出現的正則運算式,並傳回相符專案的數目。
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)
- Source:
- Regex.Count.cs
- Source:
- Regex.Count.cs
- Source:
- Regex.Count.cs
搜尋輸入範圍中所有出現的正則運算式,並傳回相符專案的數目。
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)
- Source:
- Regex.Count.cs
- Source:
- Regex.Count.cs
- Source:
- Regex.Count.cs
搜尋輸入字串中所有出現的正則運算式,並傳回相符專案的數目。
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
用來搜尋比對的字串。
傳回
符合項的數目。
例外狀況
input
為 null
。
適用於
Count(ReadOnlySpan<Char>)
- Source:
- Regex.Count.cs
- Source:
- Regex.Count.cs
- Source:
- Regex.Count.cs
搜尋輸入範圍中所有出現的正則運算式,並傳回相符專案的數目。
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>
要搜尋相符專案範圍。
傳回
符合項的數目。
適用於
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應