可能重複:
preg_replace all but numbers, letters, periods, and slash?PHP的preg_replace(從字符串替換除了字母,數字,和幾個字符的所有字符)
我有一個字符串,我想從字符串替換所有字符除外:
- 所有字母字母
- 所有數字
- @
- ,
- 。
- ;
可能重複:
preg_replace all but numbers, letters, periods, and slash?PHP的preg_replace(從字符串替換除了字母,數字,和幾個字符的所有字符)
我有一個字符串,我想從字符串替換所有字符除外:
簡單Preg_Replace與空字符串unicode的屬性:
preg_replace('/[^\[email protected],.;]/', '', $string);
[^] represents a list of characters NOT to match
\w Word character (abcABC0-9_)
,.; as the characters themselves
修改鏈接的答案包括fe你想用其中的'[]' – 2012-03-30 17:04:28
'來替換其他字符嗎?或者你想刪除? – 2012-03-30 17:04:42
我要刪除 – CBuzatu 2012-03-30 17:06:02