2010-02-04 43 views

回答

1
preg_replace("/[^a-zA-Z0-9_]/","",$string); 

或者

preg_replace("/[^a-z0-9_]/i","",$string); 

或者

preg_replace("/[^[:alpha:][:digit:]_]/","",$string) 
+1

不能'[^ A-ZA-Z0-9_]'縮短爲'\ W'? – Amarghosh 2010-02-04 05:16:50

+0

當然,是的,它可以。 – ghostdog74 2010-02-04 06:06:34

+0

值得提及'\ W'的提示:假定英文語言環境。 – cmbuckley 2012-02-03 10:21:13

相關問題