Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Regex to check for very large negative numbers

by Athanasius (Monsignor)
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

Output:

21:30 >perl 543_SoPW.pl -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):

/-\d{11,}.*\..*/

as per the answers above by moritz and BillKSmith.

Hope that helps,

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


Comment on Re: Regex to check for very large negative numbers
Select or Download Code
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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1020146]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (19)
As of 2014-07-23 14:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (145 votes), past polls