|Do you know where your variables are?|
Matching floats according to perlfaq4by jmcnamara (Monsignor)
|on Sep 25, 2002 at 11:09 UTC||Need Help??|
jmcnamara has asked for the
wisdom of the Perl Monks concerning the following question:
In response to a CB request for a regex to match floating point numbers, I suggested the regex from perlfaq4*: /^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/
At that point jarich asked if the look-ahead ?= should be a clustering ?:.
In fact the regex seems to contain other unnecessary capturing as well. The following seems to be functionally equivalent but without the capturing:
Is there any reason for this capturing in a FAQ about matching? Should it be changed?
Also, the decimal part of the floating point regex is different from the decimal regex on the previous line. Is there any reason for this inconsistency?
Here is the test frame I used: