logie17 has asked for the wisdom of the Perl Monks concerning the following question:
Strictly for pedantic reasons, is there a better solution?my $s = 'This is a test'; #Create an array my @words; while ($s =~ /(\w+)(?=\s+(\w+))/g){ #Push each found word into an array push @words, [$1,$2]; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regex Word Pairs
by Joost (Canon) on Aug 15, 2007 at 23:20 UTC | |
|
Re: Regex Word Pairs
by GrandFather (Saint) on Aug 15, 2007 at 23:46 UTC | |
|
Re: Regex Word Pairs
by graff (Chancellor) on Aug 16, 2007 at 01:37 UTC | |
|
Re: Regex Word Pairs
by goibhniu (Hermit) on Aug 16, 2007 at 00:41 UTC |