Regular Expressions 101

Community Patterns

Match quoted strings, ignoring escaped quotes

3

Regular Expression
PCRE (PHP <7.3)

/
(?| (")((?:\\"|[^"])+)\1 | (')((?:\\'|[^'])+)\1 )
/
xg

Description

Matches single or double quoted strings, and ignores backslash-escaped quotes within the string.

Submitted by Maddingue - 11 years ago