Here is the list of popular formats that you can design using regular expressions.
| Format |
Character Limit |
Field Width |
Regular Expressions |
Examples |
| DATE |
Between 0 and 10, this will allow for 10 (0-9) symbols to be entered (2 for month, 2 for day, and 4 for year. You will notice that it only adds up to 8 digits, the extra 2 is for the forward slashes that separate the month, day, and year). |
10 characters (2 for month, 2 for day, 4 for year, and 2 for the forward slashes). |
\d{2}\/\d{2}\/\d{4}
Note: \d{2} and \d{4} refers to the sequence of two and 4 digits respectively (numbers 0 to 9). \/ stands for forward slash, \ is used to interpret / as a forward slash.
More precise:
(0[1-9]|1[0-2])\/
(3[01]|[12]\d|0[1-9])\/
(1[89]\d{2}|2[01]\d{2}) |
mm/dd/yyyy
\d{2}\/\d{2}\/\d{4} |
| Phone Number |
Between 0 and 12, this will allow for 12 symbols to be entered. |
12 characters (3 for area code, 3 for prefix, 4 for line number). |
\d{3}-\d{3}-\d{4}
Note: \d{3} and \d{4} refers to the sequence of three and four digits respectively (numbers 0 to 9), - stands for a dash.
More precise:
\(?\s*\d{3}\s*\)?(\s|-)*\d{3}(\s|-)*\d{4} |
000-000-0000
\d{3}-\d{3}-\d{4} |
| Zipcode |
Between 0 and 5, this will allow for 5 digits to be entered. (there are 5 digits in a zip code). |
5 characters. |
\d{5}
Note: \d{5} refers to the sequence of five digits. |
02135
\d{5} |