in reply to Replacing consecutive tokens in 1 pass
It's tempting to usemy $string = "|90|93|foo|bar|91|92|95|96|906|"; my $result = join "", map { s/^9[0-6]$/X/; $_ } $string =~ m/(\||[^|]+)/g; print $result; __END__ |X|X|foo|bar|X|X|X|X|906|
to do the tokenizing, thensplit /\|/ $string
to reassemble them, but you'll lose the trailing "|".join "|"
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Replacing consecutive tokens in 1 pass
by ihb (Deacon) on Feb 24, 2003 at 13:10 UTC |