Regular Expressions 101

Community Patterns

Match string literals and any other character outside string

0

Regular Expression
PCRE (PHP <7.3)

/
(['""])((?:\\1|(?:(?!\1)).)*)(\1)|(?<OpenMatch>({))|(?<CloseMatch>(}))
/
gm

Description

This Regular expression is applicable to all string literals. If we want to match character outside those strings, then just need to add that character in rest of the groups.

Submitted by anonymous - 3 years ago