Regular Expressions 101

Community Patterns

All href in a tag

5

Regular Expression
PCRE (PHP <7.3)

/
<a.+?\s*href\s*=\s*["\']?([^"\'\s>]+)["\']?
/
gi

Description

Find all href in a tag

Submitted by Miron Yanovskiy - 10 years ago