Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Regex to check for very large negative numbers

by Athanasius (Archbishop)
on Feb 22, 2013 at 11:50 UTC ( [id://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,

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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2024-04-20 06:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found