why did I extract "New" instead of "New York"?
Can't tell because you don't actually show the code that generated the result you claim. The regex works as you seem to expect for me:
use strict; use warnings; my $str = <<STR; ended June 30, 2001 in conformity with accounting principles generall +y accepted in the United States of America. Also in our opinion, the related fina +ncial statement schedule, when considered in relation to the basic consolida +ted financial statements taken as a whole, presents fairly, in all materia +l respects, the information set forth therein. Melville, New York /s/KPMG LLP September 26, 2001 STR my @matches = $str =~ /^\s*(\w+),\s*(\w+ \w+)(.+?\s*LLP)$/m; print ">$_<\n" for @matches;
Prints:
>Melville< >New York< > /s/KPMG LLP<
In reply to Re^5: String contents
by GrandFather
in thread String contents
by perlyr
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |