3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $str = 'fdfqsdfqsdf%A%2%B%4%C%D%7sddsdfsdf'; $res = preg_replace_callback(',%.?,', function (array $matches) { if (preg_match(',%\d+,', $matches[0])) { return 'FOO'; } }, $str); echo $res; $res = preg_replace_callback(',%\d+?,', function (array $matches) { return 'FOO'; }, $str); echo $res;
based on Ls6Hi
Output for 5.5.0 - 7.3.0beta1
fdfqsdfqsdfFOOFOOFOOsddsdfsdffdfqsdfqsdf%AFOO%BFOO%C%DFOOsddsdfsdf