Put your quotes outside you parentheses, so only the string gets stored in $1. I'd also change from a *? to a +?, since you likely aren't interested in null strings. One case you should consider which is currently not handled, is "I like Perl," said Mary, "since it gives me more time with my lamb!" - you'll match on ' said Mary, ' in addition to what you want.
while (my $text = <DATA>) { if ($text =~ /['"](.+?)['"]/ ){ print "Found $1 \n"; } else { print "Out of luck \n"; } }
Update: Details on regular expressions can be found in the documentation in Perl regular expressions, quick reference guide, and tutorial.
In reply to Re: Trying to find all items in between quotation and speech marks
by kennethk
in thread Trying to find all items in between quotation and speech marks
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |