*** FAQ_4.72_before Mon Oct 11 18:07:09 2010
--- FAQ_4.72_after Mon Oct 11 18:09:57 2010
***************
*** 9,13 ****
if (/^[+-]?\d+$/) { print "is a +/- integer\n" }
! if (/^-?\d+\.?\d*$/) { print "is a real number\n" }
! if (/^-?(?:\d+(?:\.\d*)?|\.\d+)$/) { print "is a decimal
number\n" }
! if (/^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/)
{ print "a C float\n" }
--- 9,12 ----
if (/^[+-]?\d+$/) { print "is a +/- integer\n" }
! if (/^-?(?:\d+\.?|\.\d)\d*$/) { print "is a decimal
number\n" }
! if (/^[+-]?(?=\.?\d)\d*\.?\d*(e[+-]?\d+)?$/i)
{ print "a C float\n" }
The regex /^-?\d+\.?\d*$/ is deleted because it doesn't match
numeric strings like '.5' with no digits before the decimal point,
and is otherwise equivalent to the regex on the next line. The
other two regexes are simplified.
In article <4CB3903...@uwaterloo.ca>, David Canzi
<dmc...@uwaterloo.ca> wrote:
> Suggested change to simplify some regular expressions:
I used this opportunity to also convert the example to given-when. The
change is a13ded5516803d9baff49d9177619361dcc9d083.