public Matches ( string input ) : System.Text.RegularExpressions.MatchCollection | ||
input | string | |
return | System.Text.RegularExpressions.MatchCollection |
string input = "Visit our website at https://example.com for more information."; string pattern = @"(https?://[^\s]+)"; var matches = Regex.Matches(input, pattern); foreach (Match match in matches) { Console.WriteLine(match.Value); }
string input = "The Quick Brown Fox Jumps Over The Lazy Dog"; string pattern = @"\b[A-Z][a-z]*\b"; var matches = Regex.Matches(input, pattern); foreach (Match match in matches) { Console.WriteLine(match.Value); }This code defines a regular expression pattern that matches words that start with a capital letter and then uses the Matches method to find all the occurrences of the pattern in the input string. The resulting matches are then printed to the console. Overall, the System.Text.RegularExpressions package library provides powerful tools for working with regular expressions in C#, including the Matches method for finding all occurrences of a pattern in a string.
public Matches ( string input ) : System.Text.RegularExpressions.MatchCollection | ||
input | string | |
return | System.Text.RegularExpressions.MatchCollection |