in reply to Re: Regex trouble
in thread Regex trouble

Would that $float regex match an integer? I will have to find the (?:\.\d+) example in my Perl books to see what it does. If it matches a non-float number then I think it will solve my problem.

Replies are listed 'Best First'.
RE: RE: Re: Regex trouble
by ZZamboni (Curate) on May 17, 2000 at 01:01 UTC
    Yes it does:
    (?: - group, but don't generate back ref \. - a dot \d+ - followed by one or more digits )? - and the whole thing is optional
    So \d+(?:\.\d+)? matches a group of digits, optionally followed by a dot and more digits. So, it matches an integer or a float.

    If you want to allow things like "20." (no numbers after the dot) you would have it to \d+(?:\.\d*) (asterisk instead of plus sign after the second \d).

    --ZZamboni