use strict; use warnings; my $data = 'func1(x, "%f", "hello")'; $data =~ s/ ( func1 \( x, \s \" ) % (.) "/$1text %$2 and %$2..."/ix; print ">$data<\n";