Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
Created·2022-07-23 04:11
Flavor·PCRE2 (PHP)

/
const\s+(?<c>[a-z][a-z\d_]*)\s*=\s*(?<q>["'])(?<v>(?:\\\k<q>|(?!\k<q>).)*)(?:\k<q>)\s*;
/
gi
Open regex in editor

Description

Sometime we need to quickly parse PHP code. When no reason to use full AST parser, we can use regular expressions for find constants.

Submitted by Slava Krampetz