开发者

How to add more characters to preg replace array

i am new to php. Can anyone please tell me how to add more characte开发者_如何学Pythonrs like comma and double quotes(, ") to this preg_replace array.

$filter = preg_replace('/[^a-z0-9]/is', '', $text);


I guess you mean the character class:

/[^a-z0-9,"]/is


Should be pretty basic:

$filter = preg_replace('/[^a-z0-9," ]/is', '', $text);

For more information on Regular Expressions check out this site.

EDIT

Given the comment, added the space character to not be removed.


.. this can help you ... http://www.addedbytes.com/cheat-sheets/regular-expressions-cheat-sheet/

and you need

$new_text = preg_replace('/[^a-z0-9\s]/is', '', $text);


You may use this regular expression to remove comma and double quote but not space

$filter = preg_replace('/[,"]/is', '', $text);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜