You can find a good library of regular expressions at
These patterns will almost all work if surrounded with the forward slash. Please add successfully tested regular expressions! Examples (note that these are all one line): Note that when using regular expressions in the condition editor, do NOT include the beginning and ending slash. The 'Very precise:' versions listed here match against the first four or five digits in a number to ensure that they are valid Australian numbers.
This notation requires that international phone numbers include a leading plus sign (known as the international prefix symbol), and allows only spaces to separate groups of digits. The leading plus sign and the dot following the country code are required.
Also thanks to the international phone numbering plan (ITU-T E.164), phone numbers cannot contain more than 15 digits. : # Group but don't capture: [0-9] # Match a digit. The literal “x” character is required only if an extension is provided.
To grab the area code from the phone numbers, we can simply capture the first three digits, using the expression (\d).
Some of the possible options are 12 hour or 24 hour, with seconds or without.
One way around this is to use a long free text type question with a regular expression.
Validating a phone number using regular expression is tricky because the phone number can be written in many formats and can have extensions also.
For instance, this chapter introduces you to a number of utilities—some of them created by the authors, Jan and Steven—that let you test and debug a regular expression before you bury it in code where errors are harder to find.
And these initial chapters also show you how to use various features and options of regular expressions to make your life easier, help you understand regular expressions in order to improve their performance, and learn the subtle differences between how regular expressions are handled by different programming languages—and even different versions of your favorite programming language.