use strict; use warnings; use feature 'say'; use Data::Dump qw( pp ); my @strs = qw( "..\\".. "abc" "a\"bc" "a\\\\bc" "a\" ); my %re = ( LanX => qr/ " (?> \\\\ | \\" | [^"] )* " /x, Eily => qr/ " (?: [^"\\] | \\. )* " /x, Poss => qr/ " (?: \\\\ | \\" | [^"] )*+ " /x, ); for my $str (@strs) { say "\nTesting: <$str> = ", pp ($str); $str =~ /$re{$_}/ and say "$_ found $&" or say "$_ found nothing" for keys %re; }