正则匹配(总结)

187 阅读1分钟

不以 "hello" 开头

/^(?!hello.*)/

不以 "(hello)" 开头

/^(?![\(\(]hello[\)\)]).*/

注:^是字符串开头,(?! ) 是正向否定预查,简单说,以 xxx(?!pattern)为例,就是捕获不以pattern结尾的内容xxx

php 去除所有   和 html标签

$text = trim(preg_replace("/(\s|\&nbsp\;| |\xc2\xa0)/", "", strip_tags($text)));