3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function is_regex($string) { return false !== @preg_match($string, 'anything'); } foreach (array('/foobar/', '/foobar/i', '`test{1,3}`', '/foo', '/foo(bar/') as $candidate) { var_dump(array($candidate, is_regex($candidate))); }
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
array(2) { [0]=> string(8) "/foobar/" [1]=> bool(true) } array(2) { [0]=> string(9) "/foobar/i" [1]=> bool(true) } array(2) { [0]=> string(11) "`test{1,3}`" [1]=> bool(true) } array(2) { [0]=> string(4) "/foo" [1]=> bool(false) } array(2) { [0]=> string(9) "/foo(bar/" [1]=> bool(false) }