In a C# 2010 web application, I want to add a server side regular expression value that can edit a date in the following format:
mm/dd/yyyy where mm is month, dd is day, and yyyy is year. I want the user to be required to enter the backslashes. From what I have seen on the internet, the following 2 examples would have the code that works:
1. (0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d)
2 ^(0[1-9]|1[012])[/](0[1-9]|[12][0-9]|3[01])[/](19|20)\d\d$
Based upon the above, can you tell me the following:
1. Which method would work and why?
2. If neither method would work what would you recommend that would work?
3. From the examples above, what does [- /.] stand for? I know the dot is only one character and the / is the character that is being looked for? However what does the dash followed by a space mean? Is this the same meaning as [/]?
4. In the above examples you can see 1[012]. Does that mean that the first digit must 1 and the second digit can be either 0 or 1 or 2?
5. When looking at the regular expressions, is there a way to tell what the pattern being matched against means? Basically is there a way to tell what the regular expression means by using a tool like the .net debugger?