I Have A string that has got 2 links in it that are identical:
$str = '<a href="-randomtext-static-words-948191.html"> somewhere </a>
more text here ....
<a href="-randomtext-static-words-948191.html"> somewhere </a>';
im using Preg replace like this:
$str = preg_replace('/<a href="-(.*?)-static-words-(.*?).html">/is','<a href="?page=-$1-static-words-$2.html">',$str);
this should echo the same on both links but it only changes the second link:
output:
<a href="-randomtext-static-words-948191.html"> somewhere </a>
more text here ....
<a href="?page=-randomtext-static-words-948191.html"> somewhere </a>
However if i change the preg replace to this:
$str = preg_replace('/<a href="-(.*?)-static-words-(.*?).html">/is','<a href="?page=-$1-testing-123-$2.html">',$str);
the output changes to:
<a href="-randomtext-testing-123-948191.html"> somewhere </a>
more text here ....
<a href="?page=-randomtext-testing-123-948191.html"> somewhere </a>
what the hell is going on??? .... how can preg replace match the expression and yet only replace half of the string??
$str = '<a href="-randomtext-static-words-948191.html"> somewhere </a>
more text here ....
<a href="-randomtext-static-words-948191.html"> somewhere </a>';
im using Preg replace like this:
$str = preg_replace('/<a href="-(.*?)-static-words-(.*?).html">/is','<a href="?page=-$1-static-words-$2.html">',$str);
this should echo the same on both links but it only changes the second link:
output:
<a href="-randomtext-static-words-948191.html"> somewhere </a>
more text here ....
<a href="?page=-randomtext-static-words-948191.html"> somewhere </a>
However if i change the preg replace to this:
$str = preg_replace('/<a href="-(.*?)-static-words-(.*?).html">/is','<a href="?page=-$1-testing-123-$2.html">',$str);
the output changes to:
<a href="-randomtext-testing-123-948191.html"> somewhere </a>
more text here ....
<a href="?page=-randomtext-testing-123-948191.html"> somewhere </a>
what the hell is going on??? .... how can preg replace match the expression and yet only replace half of the string??
Comment