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);
}
出力:
テストA
テスト[
テストB
質問:test[
出力にあるのはなぜですか? 文字クラス [a-zA-Z] は、a から z および A から Z までの英字のみに一致すると想定されています。