7328
7349
my $is_string= _is_string( $replace);
7329
7350
foreach my $text_elt ($elt->descendants_or_self( $TEXT))
7331
7353
{ my $text= $text_elt->text;
7332
7354
$text=~ s{$regexp}{ _replace_var( $replace, $1, $2, $3, $4, $5, $6, $7, $8, $9)}egx;
7333
7355
$text_elt->set_text( $text);
7338
7360
my $replace_sub= ( $replace_sub{$replace} ||= _install_replace_sub( $replace));
7339
7361
my $text= $text_elt->text;
7340
7362
my $pos=0; # used to skip text that was previously matched
7341
7364
while( my( $pre_match_string, $match_string, @var)= ($text=~ m{(.*?)($regexp)}sg))
7344
7368
my $match_length = length( $match_string);
7346
7370
$replace_sub->( $match, @var);
7347
7371
# merge previous text with current one