Regular Expressions 101

Community Patterns

There does not seem to be anything here

Community Library Entry

0

Regular Expression
PCRE (PHP <7.3)

/
href=['"]([^'"]*)\.(cf|ht)ml?(\?{1}([^'"]*))?['"]
/
g

Description

If you have the source code for any page and want to get all HREF attributes and values, including URL params, that end in .cfm, .cfml, .htm, or .html. Can be easily modified for whatever document type you want (.asp, .aspx, .jsp, etc.)

I needed to do this for a project. It took me a long time to fiddle it into working shape, so I thought I'd share it for anyone else that might need it.

Submitted by anonymous - 8 years ago