开发者

Regex matching broadly after first match

开发者 https://www.devze.com 2023-02-28 19:09 出处:网络
I\'ve got the following regex <\\?php\\n//{{([^*]|[\\r\\n])*\\?> To match the following <?php //{{

I've got the following regex

<\?php\n//{{([^*]|[\r\n])*\?>

To match the following

<?php
//{{
...
?>

The problem is, once the regex matches this, it'll match the following

开发者_如何学Python<?php
...
?>

So basically, once it matches the //{{ it'll match any php tag after.

Cheers!


I don't know if I understood your regex correctly, but you can try a non-greedy solution:

<\?php\n//{{([^*]|[\r\n])*?\?>

Just append ? to the *.

0

精彩评论

暂无评论...
验证码 换一张
取 消