I am using this bit of code to identify certain links within my content and swap them for another link.
$re1='(\\\\[url\\\\])'; # Square Braces 1
$re2='.*'; # Non-greedy match on filler
$re3='(\\\\[\\\\/url\\\\])';
$articleContent .=preg_replace("/".$re1.$re2.$re3."/i", '<a href="http://www.lesson-ology.com/content.php?whereto=416">Sign Up For Access</a>', $resource[1]);
The problem with it is that it replaces everything between the tags what I want to do is replace ONLY the url and leave the rest intact.
What would the reg_ex look like to accomplish this?
Bah. Got the parameters backwards in my head. Okay so you want to take anything between square bracketed URL tags and replace it with a fixed string…
What exactly did you want to ‘save’ from the original string? Display it where? Give me an example of your input, followed by what you want it to look like when you’re done.
I need to grab the url from within a link that is surrounded by the url/url and replace that url with another. Now I need to identify the link by url/url because there are some links on the page that do not require them to be changed.