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)