Regular Expressions 101

Community Patterns

Custom HTML placeholder matcher

0

Regular Expression
PCRE (PHP <7.3)

/
\{\{[A-Za-z0-9_]+\}\}
/
g

Description

Grab all placeholder "tags" that are alphanumeric with optional underscores. In this example my placeholders are double curly braces e.g. {{MY_VARIABLE_NAME}}.

Change out the braces for whichever symbol/character you are using or add/remove more.

E.g. [[MY_VARIABLE_NAME]] would be matched with [[[A-Za-z0-9_]+]]

Submitted by John Cogan - 8 years ago