> >>>>> "RN" == Ron Newman <[EMAIL PROTECTED]> writes:
>
> RN> At 9:01 AM -0400 8/11/2001, Ranga Nathan wrote:
> >> I have a string like "Balance is: 123,245.90"
> >> when I match using /^Balance.*?([\d\,\.])/
> >> I get a number that includes the
> >> commas.
> >> Is there any way to get rid of the comms while matching?
hm, even better (or more perverse, depending on
how you look at it):
my $money = "12,345,678,901,234,567.89";
my $value ='';
$money =~ s/(\d+\.?)/$value.=$1;'';/ge;
print "value is $value \n";
it doesn't look like a while loop, but the
/g modifier on the s/// operator will substitute
ALL occurrences (so it might as well be a while).
the /e modifier says to Execute the code that
is in the REPLACEMENT spot, and the return
value will be the value replaced.
the return value is a null string, so it strips
the number out of $money. but the executed code
concats it into $value, without the parens.
again, invalid numbers get through, but
error checking wasn't in your spec.
Greg