正则表达式字断路器UNI code [英] Regex word-breaker in unicode
本文介绍了正则表达式字断路器UNI code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何转换的普通恩pression \ W + 给我整个词语的统一code - 不仅仅是ASCII
How do I convert the regular expression \w+ To give me the whole words in Unicode – not just ASCII?
我用.NET
推荐答案
这工作正常,我
string foo = "Hola, la niña está gritando en alemán: Maüschen raus!";
Regex r = new Regex(@"\w+");
MatchCollection mc = r.Matches(foo);
foreach (Match ma in mc)
{
Console.WriteLine(ma.Value);
}
它输出
Hola
la
niña
está
gritando
en
alemán
Maüschen
raus
您使用.Match(),而不是.Matches()?
Are you using .Match() instead of .Matches()?
另一种可能的解释是,你有你所期望的获得,像一个逗号的一个非字字符。
Another possible explanation is that you have a non word character in what you expect to receive, like a comma.
这篇关于正则表达式字断路器UNI code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文