Regex oRegex = new Regex(@"test[a-zA-z]");
string st = @"this is a test1 and testA and test[abc] another testB and test(xyz) again.";
foreach(Match match in oRegex.Matches(st))
{
Console.WriteLine(match.Value);
}
Output:
testA
test[
testB
Question: Why test[
in the output? The character class [a-zA-Z] is supposed to match only alpha characters a through z and A through Z.