Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]
Searches the specified input string for all occurrences of a regular expression.
Namespace: System.Text.RegularExpressions
Assembly: System.Text.RegularExpressions (in System.Text.RegularExpressions.dll)
Syntax
'Declaration
Public Function Matches ( _
input As String _
) As MatchCollection
public MatchCollection Matches(
string input
)
public:
MatchCollection^ Matches(
String^ input
)
member Matches :
input:string -> MatchCollection
public function Matches(
input : String
) : MatchCollection
Parameters
- input
Type: System. . :: . .String
The string to search for a match.
Return Value
Type: System.Text.RegularExpressions. . :: . .MatchCollection
A collection of the Match objects found by the search. If no matches are found, the method returns an empty collection object.
Remarks
The Matches(String) method is similar to the Match(String) method, except that it returns information about all the matches found in the input string, instead of a single match.
The collection includes only matches and terminates at the first non-match.
The regular expression pattern for which the Matches(String) method searches is defined by the call to one of the Regex class constructors.
The Matches method uses lazy evaluation to populate the returned MatchCollection object. Accessing members of this collection such as MatchCollection..::..Count and MatchCollection..::..CopyTo causes the collection to be populated immediately. To take advantage of lazy evaluation, you should iterate the collection by using a construct such as foreach in C# and ForEach…Next in Visual Basic.
Because of its lazy evaluation, calling the Matches(String) method does not throw a RegexMatchTimeoutException exception. However, the exception is thrown when an operation is performed on the MatchCollection object returned by this method, if the MatchTimeout property is not Regex.InfiniteMatchTimeout and a matching operation exceeds the time-out interval.
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see dd66cd4c-b087-415f-9c3e-94e3a1835f74.