3v4l.org

run code in 300+ PHP versions simultaneously
<?php $pattern = <<<REGEX / (?: <a .+?>(*SKIP)(*FAIL) | @[a-z]+ | !\w+(?:_\w+)* | %\w+(?:-\w+)* | \{[a-z]+}(?:\.[a-z]+)? ) /sx REGEX; $input = 'Hello Bob @foo <a href="/someurl/!foobar/!bar/word"> Word {foobar} </a> %foo someword !bar_baz'; echo preg_replace( $pattern, '<span class="notranslate">$0<\span>', $input );
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
Hello Bob <span class="notranslate">@foo<\span> <a href="/someurl/!foobar/!bar/word"> Word <span class="notranslate">{foobar}<\span> </a> <span class="notranslate">%foo<\span> someword <span class="notranslate">!bar_baz<\span>

preferences:
100.72 ms | 402 KiB | 62 Q