A lookahead should do the trick:
use strict; use warnings; use Test::More tests => 1; my $have = 'EST07|E9028;CP392;ALLOC_CP392|R2021||||||||||||0.46458'; my $want = 'EST07|E9028;CP392;ALLOC_CP392|R2021|#MI|#MI|#MI|#MI|#MI|#M +I|#MI|#MI|#MI|#MI|#MI|0.46458'; $have =~ s/\|(?=\|)/|#MI/g; is $have, $want;
🦛
In reply to Re: Substitution is replacing one character set out of two
by hippo
in thread Substitution is replacing one character set out of two
by sroux
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |