Re: [PBML] extract decimal numbers from a string
- From: Mukta Telang <mukta@...>
> Hi,Don't use $&.
> I want to extract decimal numbers from a string which contains blanks.
> There can be 0-2 such numbers inside the string. How to do this? I
> tried the following:
See $& section in
($one, $two) = /([0-9]+\.[0-9]+)/g;
or if you don't know how many numbers there'll be:
@numbers = /([0-9]+\.[0-9]+)/g;
The other problem is that this only accepts numbers with the decimal
part. If you also want to catch whole numbers you will want to change
the regexp to
@numbers = /([0-9]+(?:\.[0-9]+)?)/g;
===== Jenda@... === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery