#!/usr/bin/perl use strict; use warnings; my $rx = qr/(["'])(?:\\[\\"'a-z]|[^\\"'\r\n]|(?!\1)["'])*\1/; do { print $_ =~ /^($rx)/ ? "'$_' matcht: $1" : "'$_' matcht nicht!"; <>; } foreach ( q("\\\\\\"\\n\\a"), q("test"), q("Ein 2ter Test..."), q("Test mit:)."\n\"", ); <>; __END__