3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $regex = '#<tag foo="bar">([\w\s]+[^\s]+)\s?</tag>#'; echo preg_replace($regex, '\1', '<tag foo="bar">Jacopo Nuzzi</tag>'); echo preg_replace($regex, '\1', '<tag foo="bar">Jacopo Nuzzi </tag>'); echo preg_replace($regex, '\1', '<tag foo="bar">Jacopo </tag>'); echo preg_replace($regex, '\1', '<tag foo="bar">Jacopo</tag>');
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Jacopo NuzziJacopo NuzziJacopoJacopo