Match into groups
suggest changepublic string Check()
{
string input = "Hello World!";
string pattern = @"H.ll. (?<Subject>W.rld)!";
Match match = Regex.Match(input, pattern);
// World
return match.Groups["Subject"].Value;
}
If the input does not match, Match.Success is false and the group value is empty.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents