use warnings; use strict; use Regexp::Common qw/delimited/; while () { while (/$RE{delimited}{-delim=>'"'}{-keep}/g) { my $str = $3; print "<$str>\n"; } } __DATA__ nothing "hello" foo "bar" quz "hello" "world" foo "bar" quz "baz" blah "" blah "" blah nothing #### <> <>