简体   繁体   中英

Replace space character with regular expression, php

I am using the function preg_replace('/[^0-9A-F]/', '', $string) to accept only numbers and letters but at the moment is not filtering spaces, how can I include that into my reg expression? thanks

preg_replace('/[^0-9A-F ]/', '', $string)

附带说明,您只允许使用A到F的大写字母。如果要所有字母:

 preg_replace('/[^0-9A-Z ]/i', '', $string)
preg_replace('/[^0-9A-F\x20]/', '', $string)

尝试

preg_replace('/[^0-9A-F]/',( )'', $string)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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