in reply to Minimizing the amount of place holders on long identical regex

Just realised that you want to port that to C eventually so below is no good. I would just use ikegami's - don't forget to free.

You want to separate even/odd: here are 2 variations on tybalt89's which do retain the even matches as well as the odd. Assuming your system can take it:

use strict; use warnings; # trivial variation on tybalt89's to retain # both odd and even one after the other my $sample = "041424344454647484940414"; my @allin = $sample =~ /(\d)(\d)/g; # more ordered output using subs in regex my @odds_vs_evens = (); $sample =~ s/(\d)(\d)/push(@odds_vs_evens,[$1,$2])/eg; print $_->[0].'->'.$_->[1]."\n" for @odds_vs_evens;
0->4 1->4 2->4 3->4 4->4 5->4 6->4 7->4 8->4 9->4 0->4 1->4

But this is what I was after:

my $sample = "041424344454647484940414"; my %odds_vs_evens = $sample =~ /(\d)(\d)/g;

Alas it is not ordered and the World just lost some more balance.

bw, bliako