PHP preg_replace non-greedy trouble

后端 未结 2 2083
伪装坚强ぢ
伪装坚强ぢ 2021-01-18 03:57

I\'ve been using the following site to test a PHP regex so I don\'t have to constantly upload: http://www.spaweditor.com/scripts/regex/index.php

I\'m using the follo

2条回答
  •  情书的邮戳
    2021-01-18 04:25

    just an actual example of @Asaph solution. In this example ou don't need non-greediness because you can specify a count. replace just the first occurrence of @ in a line with a marker

     $line=preg_replace('/@/','zzzzxxxzzz',$line,1);
    

提交回复
热议问题