Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我最初preg_match_all对 HTMLimg标记有这种模式,但是如何找到 bbcode 的第一次出现?
preg_match_all
img
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $content, $matches);
[img]http://path/to/img.png[/img]
哪个应该返回[img]bbcode的内容
[img]
这应该这样做:
\[img\][^\[]+\[\/img\]
试试这个 :
\[img\]([^\[\]\'"]+)\[\/img\]
演示:
http://regexr.com?30mks