开发者

Terrible with regex

How can I make this regular expression replace spaces as well any non latin alpha numeric character?

preg_replace('/[^a-zA-Z0-9\s]/', '', $title)

T开发者_开发百科hanks a lot


[^...] matches anything but ....
\s matches spaces.

You don't want it to not match spaces.


Everything looks ok, you just have to assing it to a variable!

$title = preg_replace('/[^a-zA-Z0-9\s]/', '', $title)


I would just do:

<?php
preg_match_all('/[a-zA-Z0-9\s]/', $title, $out);
$ntitle = implode($out,'');
?>

EDIT: Briedis is right though, your regex works fine.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜