Hello 🙂
I am using preg_replace() to go through a file and replace all occurences of <a href="page.htm> with <a href="folder/page.htm">
I require a 'blanket' coverage/replacement of all relative links, excluding those starting with 'http://' as this means that they are off-site links.
At present I have this;
preg_replace("/a href=\"([^http:\\\\].*?)\"/", "a href=\"$NewURL$1", $FileData);
This works great untill the filename starts with an 'h', a 't', or a 'p' !!
I would be able to do what the above is doing using this;
preg_replace("/a href=\"([^h].*?)\"/", "a href=\"$NewURL$1", $FileData);
as it matches the 'h' with the first char.
I want to have [url]http://[/url] checked (as a whole), and replace if it doesnt exist.
Can anyone help??
Thanks!