Pattern library/HTML a[href] extractor regex
HTML a[href] extractor regex
A classic crawler helper. Prefer a real HTML parser for messy DOM; use regex for quick list-page link grabs.
Expression
/(?<=href\s*=\s*['"])[^'"]+/gi
How to read it
(?<=href\s*=\s*['"])After href= and opening quote (lookbehind)[^'"]+Full match is the URL value
Sample test
2 match(es)<a href="https://example.com/a">A</a> <a href='/rel'>B</a> <span>href=notquoted</span>
Starter prompt: extract href from HTML a tags, single or double quotes