How to skip first regex match?
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 I am trying to remove all the instances of a string from another string but I want to retain the first occurance e.g $toRemove = 'test'; $string = 'This is a test string to test to removing the word test'; Ouput string would be: This is a test string to test to removing the word test Easy PHP way: <?php $pattern = "/an/i"; $text = "banANA"; preg_match($pattern, $text, $matches, PREG_OFFSET_CAPTURE); preg_match($pattern, $text, $matches, 0, $matches[0][1]);