Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: Regex to check for very large negative numbers

by Athanasius (Chancellor)
on Feb 22, 2013 at 11:50 UTC ( #1020146=note: print w/replies, xml ) Need Help??

in reply to Regex to check for very large negative numbers

Hello cspctec,

You claim that the regex m/-\d+\d+\d+\d+\d+\d+\d+\d+\d+\d+\d+.*\..*/ “always matches” — but it doesn’t!

#! perl use strict; use warnings; while (<DATA>) { chomp; print "$_ is a match\n" if /-\d+\d+\d+\d+\d+\d+\d+\d+\d+\d+\d+.*\. +.*/; } __DATA__ -523566.00 -0.0013 0.0045 -32742987982758110638106318307132432131.0000


21:30 >perl -32742987982758110638106318307132432131.0000 is a match 21:39 >

Perhaps the problem lies in how you’re testing the regex against the data?

Incidentally, you can write an equivalent regex more compactly using the {n,} quantifier, which will “Match at least n times” (see “Quantifiers” in Regular Expressions):


as per the answers above by moritz and BillKSmith.

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Replies are listed 'Best First'.
Re^2: Regex to check for very large negative numbers
by cspctec (Sexton) on Feb 26, 2013 at 12:55 UTC
    Thanks for the help everyone. I think I have enough information to find a solution.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1020146]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (5)
As of 2017-10-17 21:34 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (238 votes). Check out past polls.