Is there anyway to skip the first match when using regex and php.
Or is there some way of achieveing this using str_replace.
Thanks
UPDATE
preg_replace('/((?:^.*?\btest\b)?.*?)\btest\b/', '$1', $string);
The idea is to match and capture whatever precedes each match, and plug it back in. (?:^.*?test)? causes the first instance of test to be included in the capture. (All the \bs are to avoid partial-word matches, like the test in smartest or testify.)