2011-05-28 293 views

回答

1
/[^a-z0-9\s]+/ig 

说明:

[^ Character class which matches characters NOT in the following class 
a-z All lowercase letters of the alphabet 
0-9 All numbers 
\s Whitespace characters 
] End of the character class 

i Case-insensitivity to match uppercase letters 
+0

感谢,我的猜测是,我是不是我的问题不够清楚,但我需要添加到您的是'\ s'所以我发现工作是'/ [^ a-z0-9 \ s] +/ig' – chromedude 2011-05-28 17:31:01

+1

这个正则表达式仍然匹配空格,我想你想要类似/ [^ a-z0-9 \ s] +/ig – Jeff 2011-05-28 17:31:41

+0

@chromedude:我很高兴它为你工作。修正答案为清晰。 – 2011-05-28 17:32:52

0

\W的意思是 “非单词字符”,的\w倒数,所以它将匹配空格为好。不过,我有点惊讶它不符合数字。

0

\W更准确的措辞是任何非字母数字字符\s用于任何空白

所以,这将是这样的: [^ \ s]的