Regular Expressions 101

Community Patterns

Match text inside of single/double quotes, mysql identifier tokens(`)(ignore escaped nested quotes)

0

Regular Expression
PCRE (PHP <7.3)

/
["'`](?:(?<=")[^"\\]*(?s:\\.[^"\\]*)*"|(?<=')[^'\\]*(?s:\\.[^'\\]*)*'|[^`]*`)
/
g

Description

Verbose, somewhat cryptic and very efficient pattern to match all text inside of quotes and MySQL identifier tokens.

Submitted by Phillip Weber - 3 years ago