I am having trouble with my regex for capturing consecutive capitalized words. Here is what I want the regex to capture:
\"said Polly Pocket and the toys\" -
$mystring = "the United States of America has many big cities like New York and Los Angeles, and others like Atlanta";
@phrases = $mystring =~ /[A-Z][\w'-]\*(?:\s+[A-Z][\w'-]\*)\*/g;
print "\n" . join(", ", @phrases) . "\n\n# phrases = " . scalar(@phrases) . "\n\n";
OUTPUT:
$ ./try_me.pl
United States, America, New York, Los Angeles, Atlanta
\# phrases = 5