Regex.Match Example

CSharp · Console

/Program.cs

using System;
using System.Text.RegularExpressions;

string input = "Hello, World!";
Regex regex = new Regex("Hello");
Match match = regex.Match(input);

if (match.Success)
{
    Console.WriteLine($"Pattern found: {match.Value}");
}
else
{
    Console.WriteLine("Pattern not found.");
}
;