Version Affected: All
Description:
How to write a Regex (Regular Expression) that matches the ITU E.123 and E.164 formats.
Cause:
The SecureAuth Best Practices guide mentions that phone numbers should be formatted as per ITU E.123 and/or E.164:
https://docs.secureauth.com/2212/en/best-practices-for-phone-number-and-email-formatting.html
Resolution:
Use the following regex:
^\+\d{1,3}\s\d{2,3}\s\d{2,3}\s\d{4}|^\+\d{1,3}\s\d{1,14}(\s\d{1,13})?|^\(\d{3}\)\s\d{3}\s\d{4}?
This is comprised of 3 regular expressions combined:
1. E.123
^\+\d{1,3}\s\d{2,3}\s\d{2,3}\s\d{4}
matches a 1 to 3 digit country code followed by a space, then 2 to 3 digits, another space, another 2 to 3 digits a final space then 4 digits, e.g.:
+1 123 456 7890
+31 42 123 4567
2. E.123
^\(\d{3}\)\s\d{3}\s\d{4}?
matches the standard national US 3-3-4 number format. A 3 digit area code in brackets, followed by a space, then 3 more digits, followed by another space then 4 digits e.g.:
(112) 123 4567
Note the area code must be in brackets.
3. E.164
^\+\d{1,3}\s\d{1,14}(\s\d{1,13})?
matches a 1 to 3 digit country code followed by a space then between 1 and 14 digits, optionally followed by another space and up to 13 further digits, e.g.:
+44 1234 567890
+44 1234567890
Note: E.164 allows for a maximum of 15 digits, up to 3 of which are the country code, therefor the second grouping of 14 digits can complete the number. The optional 13 characters are to allow for countries that traditionally have a space between their area code and the local number.
To enforce a Regex for a phone number field see these documents for more information
https://docs.secureauth.com/2104/en/self-service-account-update-page-configuration.html
SecureAuth Knowledge Base Articles provide information based on specific use cases and may not apply to all appliances or configurations. Be advised that these instructions could cause harm to the environment if not followed correctly or if they do not apply to the current use case.
Customers are responsible for their own due diligence prior to utilizing this information and agree that SecureAuth is not liable for any issues caused by misconfiguration directly or indirectly related to SecureAuth products.
Comments
Please sign in to leave a comment.