3v4l.org

run code in 300+ PHP versions simultaneously
<?php $meta_pattern = '/(?<=^|%3$s|\s)(?:(?!\S*%3$s\S*)\S+\s+){0,%2$d}(?:(?!\S*%3$s\S*%1$s)\S*)?%1$s\S*?(?:\s+\S+?){0,%2$d}(?=$|%3$s|\s)/'; $reg = sprintf($meta_pattern, preg_quote('search','/'), 3, preg_quote('$@','/')); $tests = array( array('input' => 'a b c d search e f g h', 'expected' => 'b c d search e f g'), array('input' => 'b c d search e f g h', 'expected' => ''), array('input' => 'a b c d search e f g', 'expected' => ''), array('input' => 'c d search e f g h', 'expected' => ''), array('input' => 'a b c d search e f', 'expected' => ''), array('input' => 'a$@b c d search e f g h', 'expected' => ''), array('input' => 'a b c d search e f g$@h', 'expected' => ''), array('input' => 'a b$@c d search e f g h', 'expected' => ''), array('input' => 'a b c d search e f$@g h', 'expected' => ''), array('input' => 'a b c$@d search e f g h', 'expected' => ''), array('input' => 'a b c d search e$@f g h', 'expected' => ''), array('input' => 'a b c d$@search e f g h', 'expected' => ''), array('input' => 'a b c d search$@e f g h', 'expected' => ''), array('input' => 'a b c d$@search$@e f g h', 'expected' => ''), array('input' => 'a b c d xsearchx e f g h', 'expected' => ''), array('input' => 'b c d xsearchx e f g h', 'expected' => ''), array('input' => 'a b c d xsearchx e f g', 'expected' => ''), array('input' => 'c d xsearchx e f g h', 'expected' => ''), array('input' => 'a b c d xsearchx e f', 'expected' => ''), array('input' => 'a$@b c d xsearchx e f g h', 'expected' => ''), array('input' => 'a b c d xsearchx e f g$@h', 'expected' => ''), array('input' => 'a b$@c d xsearchx e f g h', 'expected' => ''), array('input' => 'a b c d xsearchx e f$@g h', 'expected' => ''), array('input' => 'a b c$@d xsearchx e f g h', 'expected' => ''), array('input' => 'a b c d xsearchx e$@f g h', 'expected' => ''), array('input' => 'a b c d$@xsearchx e f g h', 'expected' => ''), array('input' => 'a b c d xsearchx$@e f g h', 'expected' => ''), array('input' => 'a b c d$@xsearchx$@e f g h', 'expected' => '') ); foreach($tests as $test) { preg_match($reg,$test['input'],$res); assert($res && !empty($res[0]) && $res[0]==$test['expected'], $test['input']); }
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught AssertionError: b c d search e f g h in /in/mIqga:39 Stack trace: #0 /in/mIqga(39): assert(false, 'b c d search e ...') #1 {main} thrown in /in/mIqga on line 39
Process exited with code 255.
Output for 5.4.8 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Warning: assert(): b c d search e f g h failed in /in/mIqga on line 39 Warning: assert(): a b c d search e f g failed in /in/mIqga on line 39 Warning: assert(): c d search e f g h failed in /in/mIqga on line 39 Warning: assert(): a b c d search e f failed in /in/mIqga on line 39 Warning: assert(): a$@b c d search e f g h failed in /in/mIqga on line 39 Warning: assert(): a b c d search e f g$@h failed in /in/mIqga on line 39 Warning: assert(): a b$@c d search e f g h failed in /in/mIqga on line 39 Warning: assert(): a b c d search e f$@g h failed in /in/mIqga on line 39 Warning: assert(): a b c$@d search e f g h failed in /in/mIqga on line 39 Warning: assert(): a b c d search e$@f g h failed in /in/mIqga on line 39 Warning: assert(): a b c d$@search e f g h failed in /in/mIqga on line 39 Warning: assert(): a b c d search$@e f g h failed in /in/mIqga on line 39 Warning: assert(): a b c d$@search$@e f g h failed in /in/mIqga on line 39 Warning: assert(): a b c d xsearchx e f g h failed in /in/mIqga on line 39 Warning: assert(): b c d xsearchx e f g h failed in /in/mIqga on line 39 Warning: assert(): a b c d xsearchx e f g failed in /in/mIqga on line 39 Warning: assert(): c d xsearchx e f g h failed in /in/mIqga on line 39 Warning: assert(): a b c d xsearchx e f failed in /in/mIqga on line 39 Warning: assert(): a$@b c d xsearchx e f g h failed in /in/mIqga on line 39 Warning: assert(): a b c d xsearchx e f g$@h failed in /in/mIqga on line 39 Warning: assert(): a b$@c d xsearchx e f g h failed in /in/mIqga on line 39 Warning: assert(): a b c d xsearchx e f$@g h failed in /in/mIqga on line 39 Warning: assert(): a b c$@d xsearchx e f g h failed in /in/mIqga on line 39 Warning: assert(): a b c d xsearchx e$@f g h failed in /in/mIqga on line 39 Warning: assert(): a b c d$@xsearchx e f g h failed in /in/mIqga on line 39 Warning: assert(): a b c d xsearchx$@e f g h failed in /in/mIqga on line 39 Warning: assert(): a b c d$@xsearchx$@e f g h failed in /in/mIqga on line 39
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.7
Warning: assert() expects exactly 1 parameter, 2 given in /in/mIqga on line 39 Warning: assert() expects exactly 1 parameter, 2 given in /in/mIqga on line 39 Warning: assert() expects exactly 1 parameter, 2 given in /in/mIqga on line 39 Warning: assert() expects exactly 1 parameter, 2 given in /in/mIqga on line 39 Warning: assert() expects exactly 1 parameter, 2 given in /in/mIqga on line 39 Warning: assert() expects exactly 1 parameter, 2 given in /in/mIqga on line 39 Warning: assert() expects exactly 1 parameter, 2 given in /in/mIqga on line 39 Warning: assert() expects exactly 1 parameter, 2 given in /in/mIqga on line 39 Warning: assert() expects exactly 1 parameter, 2 given in /in/mIqga on line 39 Warning: assert() expects exactly 1 parameter, 2 given in /in/mIqga on line 39 Warning: assert() expects exactly 1 parameter, 2 given in /in/mIqga on line 39 Warning: assert() expects exactly 1 parameter, 2 given in /in/mIqga on line 39 Warning: assert() expects exactly 1 parameter, 2 given in /in/mIqga on line 39 Warning: assert() expects exactly 1 parameter, 2 given in /in/mIqga on line 39 Warning: assert() expects exactly 1 parameter, 2 given in /in/mIqga on line 39 Warning: assert() expects exactly 1 parameter, 2 given in /in/mIqga on line 39 Warning: assert() expects exactly 1 parameter, 2 given in /in/mIqga on line 39 Warning: assert() expects exactly 1 parameter, 2 given in /in/mIqga on line 39 Warning: assert() expects exactly 1 parameter, 2 given in /in/mIqga on line 39 Warning: assert() expects exactly 1 parameter, 2 given in /in/mIqga on line 39 Warning: assert() expects exactly 1 parameter, 2 given in /in/mIqga on line 39 Warning: assert() expects exactly 1 parameter, 2 given in /in/mIqga on line 39 Warning: assert() expects exactly 1 parameter, 2 given in /in/mIqga on line 39 Warning: assert() expects exactly 1 parameter, 2 given in /in/mIqga on line 39 Warning: assert() expects exactly 1 parameter, 2 given in /in/mIqga on line 39 Warning: assert() expects exactly 1 parameter, 2 given in /in/mIqga on line 39 Warning: assert() expects exactly 1 parameter, 2 given in /in/mIqga on line 39 Warning: assert() expects exactly 1 parameter, 2 given in /in/mIqga on line 39
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
Warning: Wrong parameter count for assert() in /in/mIqga on line 39 Warning: Wrong parameter count for assert() in /in/mIqga on line 39 Warning: Wrong parameter count for assert() in /in/mIqga on line 39 Warning: Wrong parameter count for assert() in /in/mIqga on line 39 Warning: Wrong parameter count for assert() in /in/mIqga on line 39 Warning: Wrong parameter count for assert() in /in/mIqga on line 39 Warning: Wrong parameter count for assert() in /in/mIqga on line 39 Warning: Wrong parameter count for assert() in /in/mIqga on line 39 Warning: Wrong parameter count for assert() in /in/mIqga on line 39 Warning: Wrong parameter count for assert() in /in/mIqga on line 39 Warning: Wrong parameter count for assert() in /in/mIqga on line 39 Warning: Wrong parameter count for assert() in /in/mIqga on line 39 Warning: Wrong parameter count for assert() in /in/mIqga on line 39 Warning: Wrong parameter count for assert() in /in/mIqga on line 39 Warning: Wrong parameter count for assert() in /in/mIqga on line 39 Warning: Wrong parameter count for assert() in /in/mIqga on line 39 Warning: Wrong parameter count for assert() in /in/mIqga on line 39 Warning: Wrong parameter count for assert() in /in/mIqga on line 39 Warning: Wrong parameter count for assert() in /in/mIqga on line 39 Warning: Wrong parameter count for assert() in /in/mIqga on line 39 Warning: Wrong parameter count for assert() in /in/mIqga on line 39 Warning: Wrong parameter count for assert() in /in/mIqga on line 39 Warning: Wrong parameter count for assert() in /in/mIqga on line 39 Warning: Wrong parameter count for assert() in /in/mIqga on line 39 Warning: Wrong parameter count for assert() in /in/mIqga on line 39 Warning: Wrong parameter count for assert() in /in/mIqga on line 39 Warning: Wrong parameter count for assert() in /in/mIqga on line 39 Warning: Wrong parameter count for assert() in /in/mIqga on line 39

preferences:
280.45 ms | 406 KiB | 459 Q