Regular Expression to Validate Date Formats

Description


Within PaperVision Capture, regular expressions can be used to validate batch names and index fields populated by a user or an OCR process. Below are a few regular expressions that validate some common date formats:

Summary


Format 1:

MM/DD/YY HH:MM AM/PM

Regular Expression:

^([0]\d|[1][0-2])\/([0-2]\d|[3][0-1])\/\d{2}(\s([0]\d|[1][0-2])(:[0-5]\d){1,2})*\s*([aApP][mM]{0,2})?$

Examples:

12/31/2002
12/31/2002 08:00
12/31/2002 08:00 AM

Format 2:

DD/MM/YYYY HH:MM AM/PM

Regular Expression:

^([0]\d|[1][0-2])\/([0-2]\d|[3][0-1])\/\d{4}(\s([0]\d|[1][0-2])(:[0-5]\d){1,2})*\s*([aApP][mM]{0,2})?$

Examples:

31/12/2002
31/12/2002 08:00
31/12/2002 08:00 AM

Format 3:

YYYY/MM/DD HH:MM:SS

Regular Expression:

^\d{4}\/([0]\d|[1][0-2])\/([0-2]\d|[3][0-1])(\s([0]\d|[1][0-2])(:[0-5]\d){1,2})*\s*([aApP][mM]{0,2})?$

Examples:

2002/02/03
2002/02/03 12:12:18

 

Filed under PaperVision® Capture, R71.1

Last modified Feb 21, 2020

Submitted Jul 01, 2010

Related Articles

Share via Email Print