What does the following regular expression do?
^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$
Particularly, what is the purpose of the \1 part?
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.
You should check out a tutorial. There’s barely anything advanced in there (well except for that
\1you pointed to):I.e. this asserts that the input string contains exactly one date, no more no less, of format
ddmmyyyy(or could also bemmddyyyy), with possible delimiters.,-or/(and consistent delimiter usage). Note that it does not ensure a correct date. Months and days could be anything from00to99.Note that the exact meaning of
\ddepends on the regex engine and culture you are using. Usually it means[0-9](any ASCII digit). But for example in .NET it can also mean “any Unicode character that represents a digit”.