3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $test = [ 'nexus 7', 'nexus 5', 'nexus 57', ]; foreach($test as $string) { echo preg_replace(['~^(nexus)\s*(7)$~i', '~^(nexus).*+~i'], ['nexus 7', 'nexus'], $string), "\n"; }
based on haSvU
Output for 5.6.0 - 7.2.6
nexus nexus nexus