I’m asking for input for a dice game.
It really matters whether or not the number entered is divisible by ten.
I have \d+0 for the numbers that DO end in zero.
I need one for the number that DO NOT end in zero.
Thanks in advance.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Should work, I think.
This will match at least one digit followed by a non-zero digit.
However, you very likely need to embed this in some way, either by anchoring it:
to verify that the complete string only contains that number (but then you can also convert said string to a number and do a mod 10).
The way you have it currently (and also the expression in your question) it would match a number like
1203without problems for both expressions, since regexes match substrings unless you anchor them (except in some environments where they are anchored by default like that – I think Java does that).Also this works for at least two digits only, as does the expression you posted in your question. I assume that to be intentional. If not, then the
+should probably be a*in both cases.