3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $text = "This is my test string that needs to be matched and not the test keywords following it"; if (preg_match("/(.*?)test/", $text, $match)) { print_r($match); } if (preg_match("/^(.*?)test/", $text, $match)) { print_r($match); } if (preg_match("/(.*)test[\s]{1}[^a-z]{1}/", $text, $match)) { print_r($match); } ?>
Output for 4.3.0 - 5.6.25, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Array ( [0] => This is my test [1] => This is my ) Array ( [0] => This is my test [1] => This is my )