Regular Expressions 101

Community Patterns

Match valid pairwise braces in text

1

Regular Expression
PCRE (PHP <7.3)

/
\A((?:[^{}]++|\{(?-1)\})*)+\Z
/

Description

The string '{}' is valid while '{{}' is invalid as well as '}{'.

Now, is this one valid: '{{{{v{a{l{{i{d or }i}}}n}v}}al}i}d?' ?

Submitted by nowox - 9 years ago