Guest User

Untitled

a guest
Jan 9th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. #A(?:(?:(?:(?:0?[13578])|(1[02]))/31/(19|20)?dd)|(?:(?:(?:0?[13-9])|(?:1[0-2]))/(?:29|30)/(?:19|20)?dd)|(?:0?2/29/(?:19|20)(?:(?:[02468][048])|(?:[13579][26])))|(?:(?:(?:0?[1-9])|(?:1[0-2]))/(?:(?:0?[1-9])|(?:1d)|(?:2[0-8]))/(?:19|20)?dd))Z#
  2.  
  3. A # start of string
  4. (?: # group without capture
  5. # that match 31st of month 1,3,5,7,8,10,12
  6. (?: # group without capture
  7. (?: # group without capture
  8. (?: # group without capture
  9. 0? # number 0 optionnal
  10. [13578] # one digit either 1,3,5,7 or 8
  11. ) # end group
  12. | # alternative
  13. (1[02]) # 1 followed by 0 or 2
  14. ) # end group
  15. / # slash
  16. 31 # number 31
  17. / # slash
  18. (19|20)? #numbers 19 or 20 optionnal
  19. dd # 2 digits from 00 to 99
  20. ) # end group
  21. |
  22. (?:(?:(?:0?[13-9])|(?:1[0-2]))/(?:29|30)/(?:19|20)?dd)
  23. |
  24. (?:0?2/29/(?:19|20)(?:(?:[02468][048])|(?:[13579][26])))
  25. |
  26. (?:(?:(?:0?[1-9])|(?:1[0-2]))/(?:(?:0?[1-9])|(?:1d)|(?:2[0-8]))/(?:19|20)?dd)
  27. )
  28. Z
  29.  
  30. require 'date'
  31. def valid_date?( str, format="%m/%d/%Y" )
  32. Date.strptime(str,format) rescue false
  33. end
  34.  
  35. [0-1][0-9]/[0-3][0-9]/[0-9]{2}(?:[0-9]{2})?
  36.  
  37. (?:(09|04|06|11)(/|-|.)(0[1-9]|[12]d|30)(/|-|.)((?:19|20)dd))|(?:(01|03|05|07|08|10|12)(/|-|.)(0[1-9]|[12]d|3[01])(/|-|.)((?:19|20)dd))|(?:02(/|-|.)(?:(?:(0[1-9]|1d|2[0-8])(/|-|.)((?:19|20)dd))|(?:(29)(/|-|.)((?:(?:19|20)(?:04|08|12|16|20|24|28|32|36|40|44|48|52|56|60|64|68|72|76|80|84|88|92|96))|2000))))
  38.  
  39. ^((0?1?1){1}|(0?1?2){1}|([0]?3|4|5|6|7|8|9))/((0?1?2?3?1){1}|(0?1?2?(2|3|4|5|6|7|8|9|0))|(30))/[1-90]{4}$
Add Comment
Please, Sign In to add comment