in reply to Regex Word Pairs
You could go (almost) without regexes and just get the pairs yourself - at the cost of some memory (since you need to store all the separate words):
update: I'm sure there's a way to get rid of the intermediate @words array, I'm just not sure the code would get any clearer.#!/usr/local/bin/perl -w use strict; my $s = 'This is a test'; my @words = split / +/,$s; my @pairs = map [@words[$_,$_+1]],0 .. @words-2;
|
|---|