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;
In reply to Re: Regex Word Pairs
by Joost
in thread Regex Word Pairs
by logie17
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |