Output:use warnings; use strict; MAIN: { my $sq = q{'}; my $dq = q{"}; my $sq_body = qr{ [^\\$sq]* (?: \\. [^\\$sq]* )* }xms; my $dq_body = qr{ [^\\$dq]* (?: \\. [^\\$dq]* )* }xms; my $text = do { local $/; <DATA> }; # slurp all text my @quotes = grep defined && length, # ignore empty captures, null strings $text =~ m{ $dq ($dq_body) $dq | $sq ($sq_body) $sq }xmsg; s{ \n }{ }xmsg for @quotes; # make multi-line quotes into one line print "<$_> \n" for @quotes; } __DATA__ "Mary had a little lamb", she said. She thought, "I'm sure he said 'Wait a tick' before". She wondered, "What happens to an escaped \"?" Also, what happens to a "" or '' null quote? Nobody loves me 'Mary had a large and "wooly" lamb' Do not divide by '0'. Don't divide by '0'. She said, 'I'm sure it'll be ok.'
<Mary had a little lamb> <I'm sure he said 'Wait a tick' before> <What happens to an escaped \"?> <Mary had a large and "wooly" lamb> <0> <t divide by > <. She said, > <m sure it>
In reply to Re: Trying to find all items in between quotation and speech marks
by AnomalousMonk
in thread Trying to find all items in between quotation and speech marks
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |