in reply to Substitute strings
Hello kepler,
Is this what you’re looking for?
use strict; use warnings; my $data = 'func1(x, "%f", "hello")'; $data =~ s/ ( func1 \( x, \s \" ) % (.) "/$1text %$2 and %$2..."/ix; print ">$data<\n";
Output:
19:23 >perl 1694_SoPW.pl >func1(x, "text %f and %f...", "hello")< 19:23 >
Note that you have to escape the left parenthesis surrounding the function arguments, otherwise it will be interpreted as part of a grouping construct, and you’ll get Unmatched ( in regex;... warnings.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Substitute strings
by kepler (Scribe) on Sep 14, 2016 at 22:10 UTC |