【发布时间】:2013-03-28 09:36:16
【问题描述】:
我的用户输入链接结构:
++visible part of link====invisible HTML address part of link++
输入字符串:
some text here some text here ++stack overflow====http://stackoverflow.com/questions/ask++ some text here ++examplesite.com====http://www.examplesite.com/article?id=1++ some text here some text here some text here some text here ++shouldnotmatch.com====http://w ww.shouldnotmatch.com/++ some text here.
我的目标:
如果==== 和++ 之间的部分包含一个或多个空格字符,则preg_match_all 不应匹配。所以我想要的输出是与前两次链接尝试相匹配。但最后一次链接尝试不应匹配,因为 w ww 包含一个空格字符。
我的失败尝试:
\+\+(.+?)====(.+?[^ ])\+\+\+\+(.+?)====(.+?[^ {1, }])\+\+
你能纠正我吗?
【问题讨论】:
标签: php regex preg-match-all