3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = 'Hello "world". [start]this is a "mark"[end]. It should work with [start]"several" "marks"[end]'; $regex = '/(?s)"(?=((?!\[start\]).)*\[end\])/'; $replace = '&quot;'; echo preg_replace($regex, $replace, $string);

preferences:
18.89 ms | 404 KiB | 5 Q