3v4l.org

run code in 300+ PHP versions simultaneously
<?php $re = '/(text)(?!<\/a>)/m'; $str = 'this is sample text about something what is text. this is sample <a href=\'somelink.php\'>text</a> about something what is <a href=\'somelink.php\'>text</a>.'; $subst = '<a href=\'somelink.php\'>$1</a>'; $result = preg_replace($re, $subst, $str); echo $result;

preferences:
31.54 ms | 404 KiB | 5 Q