Regular Expressions 101

Community Patterns

WordPress Multipage Table of Contents header reconition

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 - 8 years ago