I
IanW
Is it possible to execute a function within a regular expression. For
example, say I have a string like this:
my $string = "Item 1 cost is: 2345.67\nItem 2 cost is: 5678.90\n";
Say I have a function ( called formatPrice() ) that processes a number, like
2345.67 in that string, and makes it look like this:
$2,345.67
So, in a regexp I want to do something like this:
$string =~ s/(Item \d+ cost is: )(.+?)\n/$1formatPrice($2)\n/g;
That doesn't work as it stands, but is this kind of thing possible?
Thanks
Ian
example, say I have a string like this:
my $string = "Item 1 cost is: 2345.67\nItem 2 cost is: 5678.90\n";
Say I have a function ( called formatPrice() ) that processes a number, like
2345.67 in that string, and makes it look like this:
$2,345.67
So, in a regexp I want to do something like this:
$string =~ s/(Item \d+ cost is: )(.+?)\n/$1formatPrice($2)\n/g;
That doesn't work as it stands, but is this kind of thing possible?
Thanks
Ian