http://qs321.pair.com?node_id=608566


in reply to Replacing Text

expect a lot of answers directing you towards various html scrubbers and token parsers, but here is the dirty regex:
s{(?:<a\s[^>]+>)([^<]+)(?:</a>)}{$1}g;
there are a lot of assumptions in there, like the link label doesn't contain < (ie, <img>), there are no line breaks, HTML is well-formed, no embedded comments (<a <!--oops--> href="">...</a>), etc, etc. but if all your use cases are like the example there, it will work.