正则表达式 排除
假若我现在有下面几行数据:
“你好,我是world”
“hello,my name is”
“地址是:http://www.baidu.com”
我想将不包含“http”字符串的行提取出来,也就是前两行,该怎么写正则表达式呢?
——解决方案——————–
先以换行分割为数组,本文来源gao@daima#com搞(%代@#码@网&搞gaodaima代码再对数组过滤就行了。
——解决方案——————–
临时想到的一个办法是:
preg_match_all(‘/\”.*?(?:http.*?)\”/’,$str,$math);
print_r($math);
获取出含有http的字符串行,然后再str_replace替换掉
——解决方案——————–
要正则做什么,直接strpos 查找每个元素不就行了。
——解决方案——————–
http://blog.sina.com.cn/s/blog_53df94780100crty.html
可以参与一下
——解决方案——————–
正则排除一般都这样写
((?!要排除的字串).)+?
http://iregex.org/blog/negate-match.html
——解决方案——————–
^(.(?!http))*$