Hi, i want to delete all characters except a-zA-Z0-9 and _ chracter. How can do that in php ?
+1
A:
preg_replace("/[^a-zA-Z0-9_]/","",$string);
Or
preg_replace("/[^a-z0-9_]/i","",$string);
Or
preg_replace("/[^[:alpha:][:digit:]_]/","",$string)
ghostdog74
2010-02-04 04:54:33
Can't `[^a-zA-Z0-9_]` be shortened to `\W`?
Amarghosh
2010-02-04 05:16:50
sure, yes it can.
ghostdog74
2010-02-04 06:06:34