简体   繁体   English

如何通过JavaScript regexp匹配不同语言的单词?

[英]How to match words in different languages by JavaScript regexp?

I have a strings in different languages. 我有不同语言的字符串。 I need to get only characters without numbers, '-', '/', ')', ... But seams JavaScript regexp '\\w' matches only English. 我只需要获得没有数字的字符,' - ','/',')',...但是接缝JavaScript regexp'\\ w'只匹配英文。
http://jsfiddle.net/d9BRC/ http://jsfiddle.net/d9BRC/

After a bit of research, it seems \\w does not handle unicode characters, you can do this with \\p{L} (Letters), but again javascript does not support this. 经过一些研究,似乎\\w不处理unicode字符,你可以用\\p{L} (字母)来做,但javascript也不支持这个。

Here is a solution , taken from this answer 这是一个解决方案 ,取自这个答案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM