Forum Moderators: coopster
$str = preg_replace("/<a href=(\"|')([^\1]+?)\1>/i", "$2", $str); $str = preg_replace("/<a href=(\"|')([^\1]+?)[\"']>/i", "$2", $str); After playing around, it looks like [^\1] ends up matching example.com" (so it matches the ", too), leaving no trailing " to match. It has the same issue if I use <a href='example.com'>, too, so it's not the double-quote that's specifically the problem.This is the point at which I grab the code and say “OK, if you’re so smart, tell me what you THINK \1 (by itself) is”. I trust you can translate that into php.
preg_replace("/<a href=(\"|')([^\\1]+?)\\1>/i", "$2", $str); Tangentially, there is no difference between [^blahblah]+ and [^blahblah]+? since the ^ means you have to stop anyway.