Regular expression validating phone number

Regular expression is an art of the programing, it’s hard to debug , learn and understand, but the powerful features are still attract many developers to code regular expression.

regular expression validating phone number-71regular expression validating phone number-33regular expression validating phone number-80regular expression validating phone number-70

“30/2/2008”, “31/02/2008” – leap year in February has 29 days only 5.However, it’s a bit hard to validate the leap year , 30 or 31 days of a month, we may need basic logic as below. “31/11/2010” – November has 30 days only [Parser] Running: E:\workspace\mkyong\Date is valid : 1/1/2010 , true Date is valid : 01/01/2020 , true Date is valid : 31/1/2010 , true Date is valid : 31/01/2020 , true Date is valid : 29/2/2008 , true Date is valid : 29/02/2008 , true Date is valid : 28/2/2009 , true Date is valid : 28/02/2009 , true Date is valid : 31/3/2010 , true Date is valid : 31/03/2010 , true Date is valid : 30/4/2010 , true Date is valid : 30/04/2010 , true Date is valid : 31/5/2010 , true Date is valid : 31/05/2010 , true Date is valid : 30/6/2010 , true Date is valid : 30/06/2010 , true Date is valid : 31/7/2010 , true Date is valid : 31/07/2010 , true Date is valid : 31/8/2010 , true Date is valid : 31/08/2010 , true Date is valid : 30/9/2010 , true Date is valid : 30/09/2010 , true Date is valid : 31/10/2010 , true Date is valid : 31/10/2010 , true Date is valid : 30/11/2010 , true Date is valid : 30/11/2010 , true Date is valid : 31/12/2010 , true Date is valid : 31/12/2010 , true Date is valid : 32/1/2010 , false Date is valid : 32/01/2020 , false Date is valid : 1/13/2010 , false Date is valid : 01/01/1820 , false Date is valid : 29/2/2007 , false Date is valid : 29/02/2007 , false Date is valid : 30/2/2008 , false Date is valid : 31/02/2008 , false Date is valid : 29/a/2008 , false Date is valid : a/02/2008 , false Date is valid : 333/2/2008 , false Date is valid : 29/02/200a , false Date is valid : 31/4/2010 , false Date is valid : 31/04/2010 , false Date is valid : 31/6/2010 , false Date is valid : 31/06/2010 , false Date is valid : 31/9/2010 , false Date is valid : 31/09/2010 , false Date is valid : 31/11/2010 , false PASSED: Valid Date Test("1/1/2010") PASSED: Valid Date Test("01/01/2020") PASSED: Valid Date Test("31/1/2010") PASSED: Valid Date Test("31/01/2020") PASSED: Valid Date Test("29/2/2008") PASSED: Valid Date Test("29/02/2008") PASSED: Valid Date Test("28/2/2009") PASSED: Valid Date Test("28/02/2009") PASSED: Valid Date Test("31/3/2010") PASSED: Valid Date Test("31/03/2010") PASSED: Valid Date Test("30/4/2010") PASSED: Valid Date Test("30/04/2010") PASSED: Valid Date Test("31/5/2010") PASSED: Valid Date Test("31/05/2010") PASSED: Valid Date Test("30/6/2010") PASSED: Valid Date Test("30/06/2010") PASSED: Valid Date Test("31/7/2010") PASSED: Valid Date Test("31/07/2010") PASSED: Valid Date Test("31/8/2010") PASSED: Valid Date Test("31/08/2010") PASSED: Valid Date Test("30/9/2010") PASSED: Valid Date Test("30/09/2010") PASSED: Valid Date Test("31/10/2010") PASSED: Valid Date Test("31/10/2010") PASSED: Valid Date Test("30/11/2010") PASSED: Valid Date Test("30/11/2010") PASSED: Valid Date Test("31/12/2010") PASSED: Valid Date Test("31/12/2010") PASSED: In Valid Date Test("32/1/2010") PASSED: In Valid Date Test("32/01/2020") PASSED: In Valid Date Test("1/13/2010") PASSED: In Valid Date Test("01/01/1820") PASSED: In Valid Date Test("29/2/2007") PASSED: In Valid Date Test("29/02/2007") PASSED: In Valid Date Test("30/2/2008") PASSED: In Valid Date Test("31/02/2008") PASSED: In Valid Date Test("29/a/2008") PASSED: In Valid Date Test("a/02/2008") PASSED: In Valid Date Test("333/2/2008") PASSED: In Valid Date Test("29/02/200a") PASSED: In Valid Date Test("31/4/2010") PASSED: In Valid Date Test("31/04/2010") PASSED: In Valid Date Test("31/6/2010") PASSED: In Valid Date Test("31/06/2010") PASSED: In Valid Date Test("31/9/2010") PASSED: In Valid Date Test("31/09/2010") PASSED: In Valid Date Test("31/11/2010") =============================================== com.mkyong.regex.=.*[A-Z]) # must contains one uppercase characters (?=.*[@#$%]) # must contains one special symbols in the list "@#$%" . If three digits appear, it must start either 0 or 1 # e.g ([0-9], [0-9][0-9],[0-1][0-9][0-9]) | # ..2[0-4]\d # start with 2, follow by 0-4 and end with any digit (2[0-4][0-9]) | # ..25[0-5] # start with 2, follow by 5 and end with 0-5 (25[0-5]) ) # end of group #2 \. # repeat with 3 time (3x) $ #end of the line ( #start of group #1 1[012] # start with 10, 11, 12 | # or [1-9] # start with 1,2,...9 ) #end of group #1 : # follow by a semi colon (:) [0-5][0-9] # follow by 0..5 and 0..9, which means 00 to 59 (\s)? i) # next checking is case insensitive (am|pm) # follow by am or pm ( #start of group #1 [01]?The password won't appear on the screen as you type and most browsers also won't 'remember' the values entered in fields as they do with other form elements.

485

Leave a Reply