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]*)')
/
gm
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)
Substitution
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)