3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $expr = <<<REGEX / \b # word boundary [a-z]{2,3} # 2 or 3 letters \s* # optional spaces [0-9]{2,3} # 2 or 3 digits \s* # optional spaces [a-z]? # optional single letter \b # word boundary /ix REGEX; $strs = array( 'Honda : CRF 2005 honda crf 50 dirt bike pit bike', 'Honda : XR 2001 honda xr 400 r', 'Honda : CRF 2005 honda crf50 dirt bike pit bike', 'Honda : XR 2001 honda xr400r', ); foreach ($strs as $str) { if (preg_match($expr, $str, $matches)) { var_dump($match[0]); } }
based on dAod7
Output for 5.0.4 - 5.1.1, 5.1.3 - 7.1.0
Notice: Undefined variable: match in /in/B3moi on line 24 NULL Notice: Undefined variable: match in /in/B3moi on line 24 NULL Notice: Undefined variable: match in /in/B3moi on line 24 NULL Notice: Undefined variable: match in /in/B3moi on line 24 NULL
Output for 5.1.2
Notice: Undefined variable: match in /in/B3moi on line 25 NULL Notice: Undefined variable: match in /in/B3moi on line 25 NULL Notice: Undefined variable: match in /in/B3moi on line 25 NULL Notice: Undefined variable: match in /in/B3moi on line 25 NULL
Output for 4.3.0 - 4.4.1, 4.4.3 - 5.0.3
Notice: Undefined variable: match in /in/B3moi on line 24 NULL Notice: Undefined variable: match in /in/B3moi on line 24 NULL Notice: Undefined variable: match in /in/B3moi on line 24 NULL Notice: Undefined variable: match in /in/B3moi on line 24 NULL
Output for 4.4.2
Notice: Undefined variable: match in /in/B3moi on line 25 NULL Notice: Undefined variable: match in /in/B3moi on line 25 NULL Notice: Undefined variable: match in /in/B3moi on line 25 NULL Notice: Undefined variable: match in /in/B3moi on line 25 NULL