3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $str = "TEST DEHUMIDIFIER, MUNTERS (M11L) / / / / / / / M11L 230V, 50Hz, 0.21Kw"; print $str . PHP_EOL . '-------------------' . PHP_EOL; preg_match_all("/(\b[a-zA-Z-]{3,}\b)+?/", $str, $matches); print_r($matches[0]); $foo = $matches[0]; foreach ($foo as $bar) { print $bar . ': '; print preg_match('/^[a-z0-9]+([a-z0-9-]+[a-z0-9])?$/iD', $bar); print PHP_EOL; } // stripMeasurements $pattern = "!(?<=\A|[, :-=])\d+[- ]{0,3}(\"|barrel|bag|bottle|box|can|coil|cartridge|case|carton|cup|cylinder|degree|drum|dozen|foot|feet|squarefoot|gallon(us)|inch|gram|hole|jar|kilogram|pound|length|litre|milli-litre|meter|metre|milli-letre|milimetre|squaremetre|cubicmetre|metre|roll|numberofrolls|packet|piece|pail|pair|sack|set|sheet|shortton|tin|metricton|ton|thread|tonne|a|bar|bg|bo|bx|b|ca|cm|cl|cq|ct|cu|cy|cm2|c|deg|dr|din|fot|ftk|gll|grm|gm|hz|in|jr|kg|kgm|kgf|kwh|kw|l|lbr|ln|ltr|rpm|mlt|c2|cc3|c3|ma|m2|m3|mt3|mt2|ml|mm|mmt|mtk|mtq|mtr|m|nrl|pa|pin|psi|pkt|pce|pcs|rol|sa|set|st|stn|tn|tne|tu|va|v|x)[s]?(?=\Z|[, :-=])!i"; print preg_replace($pattern, " ", $str) . PHP_EOL; preg_match_all( "#(?=[a-z-]*\d)[a-zA-Z0-9-.]{4,}(?<=[a-z0-9])#i", $str, $partCandidates ); print_r($partCandidates[0]); foreach ($partCandidates[0] as $part) { print $part . ':' . preg_match("![[\d]+?[-x\/.]{1}]?[\d]+(\"|barrel|bag|bottle|box|can|coil|cartridge|case|carton|cup|cylinder|degree|drum|dozen|foot|feet|squarefoot|gallon(us)|inch|gram|hole|jar|kilogram|pound|length|litre|milli-litre|meter|metre|milli-letre|milimetre|squaremetre|cubicmetre|metre|roll|numberofrolls|packet|piece|pail|pair|sack|set|sheet|shortton|tin|metricton|ton|thread|tonne|a|bar|bg|bo|bx|b|ca|cm|cl|cq|ct|cu|cy|cm2|c|deg|dr|din|fot|ftk|gll|grm|gm|hz|in|jr|kg|kgm|kgf|kwh|kw|l|lbr|ln|ltr|rpm|mlt|c2|cc3|c3|m2|ma|m3|mt3|mt2|ml|mm|mmt|mtk|mtq|mtr|m|nrl|pa|pin|psi|pkt|pce|pcs|rol|sa|set|st|stn|tn|tne|tu|va|v|x)$!i", $part) . PHP_EOL; }
Output for 4.3.10 - 4.4.9, 5.0.2 - 5.6.21, hhvm-3.12.0, 7.0.0 - 7.1.0
TEST DEHUMIDIFIER, MUNTERS (M11L) / / / / / / / M11L 230V, 50Hz, 0.21Kw ------------------- Array ( [0] => TEST [1] => DEHUMIDIFIER [2] => MUNTERS ) TEST: 1 DEHUMIDIFIER: 1 MUNTERS: 1 TEST DEHUMIDIFIER, MUNTERS (M11L) / / / / / / / M11L , , 0.21Kw Array ( [0] => M11L [1] => M11L [2] => 230V [3] => 50Hz [4] => 0.21Kw ) M11L:0 M11L:0 230V:0 50Hz:0 0.21Kw:1
Output for hhvm-3.10.0

Process exited with code 153.
Output for 4.3.0 - 4.3.9, 5.0.0 - 5.0.1
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/aKrbU on line 3 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/aKrbU on line 3 TEST DEHUMIDIFIER, MUNTERS (M11L) / / / / / / / M11L 230V, 50Hz, 0.21KwPHP_EOL-------------------PHP_EOLArray ( [0] => TEST [1] => DEHUMIDIFIER [2] => MUNTERS ) TEST: 1 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/aKrbU on line 12 PHP_EOLDEHUMIDIFIER: 1 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/aKrbU on line 12 PHP_EOLMUNTERS: 1 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/aKrbU on line 12 PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/aKrbU on line 18 TEST DEHUMIDIFIER, MUNTERS (M11L) / / / / / / / M11L , , 0.21KwPHP_EOLArray ( [0] => M11L [1] => M11L [2] => 230V [3] => 50Hz [4] => 0.21Kw ) Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/aKrbU on line 29 M11L:0PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/aKrbU on line 29 M11L:0PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/aKrbU on line 29 230V:0PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/aKrbU on line 29 50Hz:0PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/aKrbU on line 29 0.21Kw:1PHP_EOL