my $rx = qr/ (["']) # save " or ' in $1 (?: # group [\\]{2} # double escape | # OR [\\]$1 # escaped end of data | # OR [\\][a-z] # escaped letter ( escape sequence ) | # OR [^\\\n\r$1] # other useable characters ) * # end group, any times $1 # content of $1 /x; # ...später dann... $string =~ /^($rx)/;