下面的代码片段打印假
:
Console.WriteLine(Regex.IsMatch("abc", @"[[:alpha:]]"));
但这种打印真
:
Console.WriteLine(Regex.IsMatch("abc", @"[a-zA-Z]"));
为什么呢?难道他们不应该等同?
Why? Shouldn't they be equivalent?
.NET的正则表达式不支持POSIX字符类。然而他们支持统一code组。
.NET Regexes don't support the Posix character classes. They do however support Unicode groups.
这会工作:
Regex.IsMatch(ABC,@^ \ p {L〕+ $);
在 \ p {L〕
场小组赛全部统一code字母。
The \p{L}
group matches all Unicode letters.
在这里看到更多的信息:
See here for more information:
http://msdn.microsoft.com/en-us/library/20bw873z.aspx#CategoryOrBlock