标签: php regex special-characters
我有这样的字符串:
hello this is my_string is-very-cool & another stuff
如何通过所有特殊字符爆炸(?)我的字符串,但允许空格, - 和_?
任何想法?
答案 0 :(得分:3)
preg_split('/[^\w -]/', $string)
这将拆分任何非a-z,0-9,_, - 或空格。