Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE (PHP <7.3)

/
(<h([1-3]{1})[^>]*?(?! id)(?:id=\"([^\"]*)\"[^>]*)?>)(.*)<\/h\2>|<!--nextpage-->
/
g

Description

Finds h1-h3, its id if have one and the title.

Submitted by Morning train - 9 years ago