Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Regex to check for very large negative numbers

by Old_Gray_Bear (Bishop)
on Feb 21, 2013 at 20:27 UTC ( #1020001=note: print w/ replies, xml ) Need Help??


in reply to Regex to check for very large negative numbers

I think you are approaching this the wrong way around.

  1. Ask yourself "what is the reasonable range of expected data?" (-A <= data <= B).
  2. Now set your lower limit at 2*A and your upper limit at 2*B
  3. Validate your data by asking two questions: 1) is is less than my lower limit? 2) Is it greater than my upper limit?
  4. If the answer to either of these questions is 'yes', drop the data point. (Personally, I'd log it as well for later review.)
Pattern Matching is a Useful Tool, just not a Universal Tool.

Update: Cleaned up the wording. (I hate it when I change metaphors in mid stream.)

----
I Go Back to Sleep, Now.

OGB


Comment on Re: Regex to check for very large negative numbers
Re^2: Regex to check for very large negative numbers
by igelkott (Curate) on Feb 22, 2013 at 10:13 UTC

    Obviously good approach but wouldn't a regex be more appropriate in this case?

    Whether it's moritz's negative check (as the OP requested) or BillKSmith's positive approach, it seems better to avoid interpretation of a huge number that won't be needed anyway.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2014-11-29 05:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (203 votes), past polls