Please enable JavaScript to use regex101
/
^
r
e
g
e
x
[
\
-
_
]
?
1
0
1
$
/
i
Reg
ular
Ex
pressions
101
Upgrade to Pro
Enterprise
Regular Expression
/
(?|"([^\n"\\]*(?:\\.[^\n"\\]*)*)"|'([^\n'\\]*(?:\\.[^\n'\\]*)*)')
/
gs
Input 1
1
New
My text "can contain" both single 'and double"' quotes. The quotes "can also be 'nested" as you can see. Valid / invalid Valid: This is "A text" (A text) Valid: This is 'A text' (A text) Valid: This is "A 'text" (A ]text) Valid: This is 'A "text' (A [text) Invalid: This is "A text (Uneven quotes 1) Invalid: This is 'A text (Uneven quotes 1) Invalid: This is "A "text" (Uneven quotes 3) Invalid: This is 'A 'text'(Uneven quotes 3) My text "can \"contain\"" both single 'and \'double\'"' quotes. The quotes "can also be\" \' 'nested" as you can see.
Extraction
My text "can contain" both single 'and double"' quotes. The quotes "can also be 'nested" as you can see. Valid / invalid Valid: This is "A text" (A text) Valid: This is 'A text' (A text) Valid: This is "A 'text" (A ]text) Valid: This is 'A "text' (A [text) Invalid: This is "A text (Uneven quotes 1) Invalid: This is 'A text (Uneven quotes 1) Invalid: This is "A "text" (Uneven quotes 3) Invalid: This is 'A 'text'(Uneven quotes 3) My text "can \"contain\"" both single 'and \'double\'"' quotes. The quotes "can also be\" \' 'nested" as you can see.