I\'m useless with regular expressions and haven\'t been able to google myself a clear solution to this one.
I want to search+replace some text ($content) for any url
Here is the gist of what I came up with. Hopefully it helps someone:
$content = get_the_content(); $pattern = "/(?<=href=(\"|'))[^\"']+(?=(\"|'))/"; $newurl = get_permalink(); $content = preg_replace($pattern,$newurl,$content); echo $content;
Mucho thanko to @WiseGuyEh