in reply to Regex for matching dotted numbers
Given that I'm lazy today, I'll give a short answer anyway (untested):
my @nums = $dotted_num_string =~ /^(\d+)(?:\.(\d+))*$/;
...which captures the numeric parts in @nums.
If you have some known restriction on how many or how few numeric fields there are, you can use a quantifier:
my @nums = $dotted_num_string =~ /^(\d+)(\.\d+){3,5}$/;
gives 4 to 6 numeric fields.
-QM
--
Quantum Mechanics: The dreams stuff is made of
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regex for matching dotted numbers
by AnomalousMonk (Archbishop) on Jul 21, 2014 at 13:12 UTC | |
by QM (Parson) on Jul 21, 2014 at 19:54 UTC |