I want to replace all matching occurrences at start of the string.
Here is a use case.
www.example.com/example.com/http://example.com/www.abc.com/www.example.com/xyz.com/example.com
should become
www.abc.com/www.example.com/xyz.com/example.com
every matching occurrence should be removed until a non matching string encounters.
I am using preg_replace
currently I have this regular expression
'/(http:\/\/){0,1}(www.){0,1}example.com(\/)*/i'
The problem is that it replaces all matching strings.
I want to replace matched strings only at the start, if matching fails once after that it should not replace any thing. Any helping suggestions ?
Thanks.