How to match anchor tags and links?

The following regex will help you match anchor tags in HTML. It will capture the href value in capture group 1 and the link’s text in capture group 2.

Example: <a href="https://google.com">GOOGLE</a>

Regex: <a[^>]+href=\"(.*?)\"[^>]*>(.*?)</a>



×

Subscribe

The latest tutorials sent straight to your inbox.