Monday, 15 March 2010

java - Compare specific date format in regex -


I have a regex string and the second string that I pass through a config file in my code.

  one = daily_ [0- 9] {4} _ [0- 9] {2} _ [0- 9] {2} b = YYYY_MM_DD  

Examples can be: Daily_2015_03_17, Daily_2014_02_10 ....

Now I want to check that the string "A" is the valid date format of string "A" specified by.

How do I get your resuscule (this does not check the leap year):

>

  string b = (daily_) (\ d {4} _) (((0 [13578] | [1] [02]) _ (0 [1- 9] | [1 | 2] [0-9] | [3] [0 | 1]) | ((0 [469] | 11) _ (0 [1-9] | [1 | 2] [0 -9] | 30)) | (02_ (0 [1-9] | [1 | 2] [0-9]))); A = "daily_2015_03_30"; Boolean Race = a.matches (b); // race says "true" if a match occurs  

No comments:

Post a Comment