in reply to Re^3: Regular Expression rematch
in thread Regular Expression rematch
For reasons I don't know, the results can be quite different depending on the version of perl.
use strict; use warnings; print "Perl version $]\n"; my $str = "1 plus 2 equals 3 but in this example, AX plus BY equals CZ +, DA plus EBCDEF plus FGH equals G and H plus I plus J plus K equals +L and I wonder what one gets from 7 plus Z"; my $word = "plus"; my @results = $str =~ m{ (?= (\S+ \s+ \Q$word\E \s+ \S+) ) }xmsg; print join("\n", @results), "\n";
produces
Perl version 5.008008 1 plus 2 AX plus BY X plus BY DA plus EBCDEF A plus EBCDEF EBCDEF plus FGH BCDEF plus FGH CDEF plus FGH DEF plus FGH EF plus FGH F plus FGH H plus I I plus J J plus K 7 plus Z
or
Perl version 5.010000 1 plus 2 AX plus BY DA plus EBCDEF EBCDEF plus FGH H plus I I plus J J plus K 7 plus Z
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Regular Expression rematch
by ikegami (Patriarch) on Aug 16, 2009 at 06:04 UTC | |
by ig (Vicar) on Aug 16, 2009 at 07:24 UTC | |
by ikegami (Patriarch) on Aug 16, 2009 at 08:20 UTC |