What is the regular expression for Date format dd\mm\yyyy? I am unable to find out regex for this format?
Share
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.
In my opinion, it’s best to verify the formatting using a regular expression, but verify the validity with code (Java, in your case). It would be absurdly verbose to try to check things like differing days per month and leap years with a regular expression.
I suggest parsing the date using a regex like
([0-9]{2})\\([0-9]{2})\\([0-9]{4}), then extract each piece (dd,mm, andyyyy, respectively), and try to create ajava.util.Dateobject out of them.Note the following:
/) not backslashes (\),\\\\for two backslash (\\) characters. In java strings to write a backslash we need the escape character (which is again a\).