fork(1) download
  1. <?php
  2.  
  3. $string = 'Hello "world". [start]this is a "mark"[end]. It should work with [start]"several" "marks"[end]';
  4. $regex = '/\[start].*?\[end]/s';
  5. $string = preg_replace_callback($regex, function($m) {
  6. return str_replace('"', '&quot;', $m[0]);
  7. },$string);
  8. echo $string;
Success #stdin #stdout 0.02s 52432KB
stdin
Standard input is empty
stdout
Hello "world". [start]this is a &quot;mark&quot;[end]. It should work with [start]&quot;several&quot; &quot;marks&quot;[end]