in reply to Global regexp
Not sure your parameters. Do you mean all pairs of numerically consecutive digits? Or just adjacent digits? Does the string contain alphabetics? Although everyone loves to show off their regex foo, not all solutions require a regex. Perhaps this:
my $s = "abc12341xyz"; my @pairs = grep /\d\d/, map { substr $s, $_, 2 } (0..length($s)-2); print join " ", @pairs; 12 23 34 41
s//----->\t/;$~="JAPH";s//\r<$~~/;{s|~$~-|-~$~|||s |-$~~|$~~-|||s,<$~~,<~$~,,s,~$~>,$~~>,, $|=1,select$,,$,,$,,1e-1;print;redo}
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Global regexp
by Anonymous Monk on Jun 17, 2008 at 09:21 UTC | |
by ikegami (Patriarch) on Jun 17, 2008 at 16:35 UTC | |
by Anonymous Monk on Jun 18, 2008 at 04:38 UTC | |
by ikegami (Patriarch) on Jun 18, 2008 at 14:48 UTC | |
by Corion (Patriarch) on Jun 17, 2008 at 09:28 UTC | |
by Anonymous Monk on Jun 17, 2008 at 12:24 UTC | |
by Corion (Patriarch) on Jun 17, 2008 at 12:29 UTC | |
by Anonymous Monk on Jun 18, 2008 at 04:43 UTC | |
by lodin (Hermit) on Jun 17, 2008 at 18:09 UTC | |
by Anonymous Monk on Jun 18, 2008 at 04:42 UTC | |
by starbolin (Hermit) on Jun 17, 2008 at 16:31 UTC |
In Section
Seekers of Perl Wisdom