this is my regex for digital dnumbers:
\d+(.\d+)+(,\d+)
but now i have problem that number 3 or 30 are not valid any more. What must be my regex that also number 3 and 40 will pass.
Thx
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.
The
+in regex means “at least one”, whereas the*means “zero or more” and the?means “either one or none”.Also, you have to escape periods as
\.since otherwise the.character is a special character in regex meaning “any single character”.If you want to make sure that the
.‘s in the number (if present) always separate digits by groups of 3, you could use this (the{x}syntax means “exactly x repetitions”):Or to force thousands separators all the time, you could use this (the
{x,y}syntax means “anywhere from x to y repetitions):