code_junkie

Regex - is there something I've done wrong?

Nov 12th, 2011
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. var r = new RegExp(
  2. "^(:19|20)?[0-9][0-9]" // optional 19/20 start followed by 2 numbers
  3. + "-" // a hyphen
  4. + "(:0?[1-9]|1[0-2])" // optional 0 followed by 1-9, or 10, 11, 12
  5. + "-" // a hyphen
  6. + "(:3[01]|[12][0-9]|0?[1-9])$" // you get the idea.
  7. );
  8. r.test("2008-07-01"); // == false
Add Comment
Please, Sign In to add comment