<?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 git.master, git.master_jit, rfc.property-hooks
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.
This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.