Updated on

Filter links from HTML

With this neat little regex.

A quick & dirty way to filter all links from a given piece of HTML code. Does not filter attributes.

<\/*?(?![^>]*?\b(?:a)\b)[^>]*?>

Another one also filters linktext:

(?i)<a\shref=\"([^>]+)\">(.+?)</a>

Replace it with:

$1    $2

What's next?

Not much really. But if you think this was useful to you, it might be for others also. Feel free to share:

Email, LinkedIn, WhatsApp, or click / push the link below to copy it:

https://eikhart.com/blog/filter-links-from-html