Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^3: regex

by periapt (Hermit)
on Sep 22, 2004 at 17:24 UTC ( [id://392985]=note: print w/replies, xml ) Need Help??


in reply to Re^2: regex
in thread How do I detect if a number has a minus sign?

Actually, you pretty much have it at this point. $sign, $num & $den contain the info you need. A series of decision statements should handle the rest (how you implement the decision tree is highly dependant on your purpose) so ...
if($sign eq '-'){ do something ... } if(not $den){ do something .... } # $den will be undefined if no denom +inator is found if(length($num_ == 3){ do something ... }
There are any number of ways you can identify/validate conditions on your term. (duff's reference has several). The idea is to peel off the parts of your test value that you need into seperate variables and then check the conditions individually. I have found that trying to find some super regex that does it all isn't worth the effort (although it can be aesthetically pleasing)


PJ
use strict; use warnings; use diagnostics; (if needed)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2024-04-23 10:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found