You are pretty close. Here is what I came up with. Capture the variable part (the numbers) so that you can use the same value in the replacement.
#!/usr/bin/perl -w
use strict;
my $dat = 'size="10">20iliX 234bvc 234yyyyy size="10">35iliX';
$dat =~ s/size="10">(\d{1,2})iliX/size="10" text-anchor="end">$1iliX/g
+;
print $dat;
#size="10" text-anchor="end">20iliX 234bvc 234yyyyy size="10" text-anc
+hor="end">35iliX
Ooops! now I see that the variable is the X and not the ##. That makes
things slightly different, capture the X digits instead of "##'
my $dat = 'size="10">##ili22 234bvc 234yyyyy size="10">##ili33';
$dat =~ s/size="10"\>##ili(\d{1,2})/size="10" text-anchor="end">##ili$
+1/g;
print $dat;
#size="10" text-anchor="end">##ili22 234bvc 234yyyyy size="10" text-an
+chor="end">##ili33
Insert: Another Oops, saw post from ww. Can you show data from real thing? My simple example works, but obviously something more complex is going on. |