in reply to Re^3: Regex for max length float
in thread Regex for max length float

Hmm... yes, but it's not really just the decimal that's optional, right? It's the decimal and the trailing digits. So something like this:

$float =~ m/ \A # beggining of string \d{0,$max_lhs} # 0 to $max_lhs digits (?= # non capturing grouping \. # decimal point \d{1,$max_rhs} # 1 to $max_rhs digits )? # grouping is optional \z # end of string /xms;

should do it, right? I haven't had a chance to test it, but that's the correct use of (?= )?, right?

Replies are listed 'Best First'.
Re^5: Regex for max length float
by ikegami (Patriarch) on Mar 14, 2007 at 16:32 UTC

    (?:...) is non-capturing grouping.
    (?=...) is zero-width positive lookahead, which isn't appropriate here.