Find all matches

suggest change

Using

using System.Text.RegularExpressions;

Code

static void Main(string[] args)
{
    string input = "Carrot Banana Apple Cherry Clementine Grape";
    // Find words that start with uppercase 'C'
    string pattern = @"\bC\w*\b";

    MatchCollection matches = Regex.Matches(input, pattern);
    foreach (Match m in matches)
        Console.WriteLine(m.Value);
}

Output

Carrot
Cherry
Clementine

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents