开发者

Only filter out the alphanumeric text

开发者 https://www.devze.com 2023-03-27 12:37 出处:网络
How can I only take the alphanumeric text and spaces from a given text. I can do the regex and I have come up with -> [A-Za-z0-9 ]+ but I dont know any functions in php which will take the text and a

How can I only take the alphanumeric text and spaces from a given text.

I can do the regex and I have come up with -> [A-Za-z0-9 ]+ but I dont know any functions in php which will take the text and apply th开发者_StackOverflow中文版at rule and return me the match.


You can use the preg_grep function. See the PHP documentation for details.


mixed preg_replace ( mixed $pattern , mixed $replacement , mixed $subject [, int $limit = -1 [, int &$count ]] )

(source: http://www.php.net/manual/en/function.preg-replace.php)

What about doing a little bit of research before asking questions?

0

精彩评论

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