如何使用正则表达式过滤特殊字符,不包括法语字母 [英] How to filter the special characters, not including the French letters, using regular expressions
本文介绍了如何使用正则表达式过滤特殊字符,不包括法语字母的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用替换(/ [^ \w\s] | _ / g,).replace(/ \ s + / g,)
可以过滤所有特殊字符,
但我不想过滤法语字母。
解决方案
你可以使用这个:
/ [^ \\\\\\||||||||||||||||||||||||||||||||||||||||||||||||| / pre>
您不需要对 _
进行特殊处理,因为它包含在 \ w
参考
< a href =http://en.wikipedia.org/wiki/French_alphabet =nofollow>法语拼写
I use replace(/[^\w\s]|_/g, "").replace(/\s+/g, " ")
can filter all special character,
but I don't want filter the French letters.
解决方案 You can use this:
/[^\w\sàâäôéèëêïîçùûüÿæœÀÂÄÔÉÈËÊÏΟÇÙÛÜÆŒ]/g
You don't need special treatment for the _
as it is included in \w
Reference
这篇关于如何使用正则表达式过滤特殊字符,不包括法语字母的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文