简体   繁体   English

PHP ereg_replace允许空格

[英]PHP ereg_replace allow spaces

using preg_replace I want to allow only alphanumeric and spaces, but ereg_replace("[^A-Za-z0-9\\w\\] deletes all spaces. 使用preg_replace我只想允许字母数字和空格,但是ereg_replace("[^A-Za-z0-9\\w\\]删除所有空格。

What could I do in order to fix it? 我该怎么做才能修复它?

Thanks in advance 提前致谢

you forgot a space 你忘了一个空间

[^A-Za-z0-9\w\ ]
______________^

eg: 例如:

$returnValue = preg_replace('@[^A-Za-z0-9\w\ ]@', '', 'I forgot a %space!!!');
// I forgot a space

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM