2011-05-28 294 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]的