RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Expressions by User

   Displaying page 1 of 1 pages; Items 1 to 1
Title Test Details YYYYMMDDHHMMSS - common interface datetime format with or without time
Expression
^[0-9]{4}(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|3[0-1])($|(([01][0-9]|2[0-3])[0-5][0-9][0-5][0-9])$)
Description
This expression validate the YYYYMMDDHHMMSS datetime format but also only the date YYYYMMDD. It does not control month length or leap years. Made for a SAP retail sales tickets interface. For XML pattern facet this would do: ([0-9]{4}(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|3[0-1])(([01][0-9]|2[0-3])[0-5][0-9][0-5][0-9]))|([0-9]{4}(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|3[0-1]))
Matches
20200707181818 | 20200707 | 20200231010000 | 20200931 | 00011231235959 | 00000101
Non-Matches
20201232 | 20201301 | 20200028 | 20200500 | 20200707235978 | 20201231128533 | 20200327453030
Author Rating: The rating for this expression. Juan Carlos Gutiérrez Deliot
   Displaying page 1 of 1 pages; Items 1 to 1

Copyright © 2001-2025, RegexAdvice.com | ASP.NET Tutorials