Community Library Entry

1

Regular Expression
Created·2026-02-11 16:32
Updated·2026-02-11 16:35
Flavor·PCRE2 (PHP)

@
^([ \t]+)function\s++.*+((?>\n++(?!\1[}]$).++)*+\n++\1[}]) # Only match the function which contains 'second' (*scs:(2)[\S\s]*\bsecond\b)
@
gmx
Open regex in editor

Description

Capture the contents of a function, then use (*scs:...) to limit the match results to those whose captured text contains specific text.

Submitted by OnlineCop