Regular Expression Examples

Last modified on 2022/08/17 10:39

The regular expression examples provided in the wizard verify that the input string contains the pattern.

You can use these examples in constraints of questionnaires.

Best Practice

  • To make sure the input does not contain other information, add ^ at the begining and $ at the end of the regular expression.

example  Add the characters displayed in yellow below.

^.+@[^\.].*\.[a-z]{2,}/$

Examples

Expected format Examples Corresponding regular expression
European phone number, with or without extra information
  • +(33)1.55.85.91.17 (office)
  • +(33)7.00.01.02.03 (mobile)
(\+\([0-9]{1,3}\)|[0-9])[0-9][-.]([0-9]{2})[-.]([0-9]{2})[-.]([0-9]{2})[-.]([0-9]{2})
One European phone number, without any other information
  • +(33)1.55.85.91.17
  • 01.55.56.57.17
^(\+\([0-9]{1,3}\)|[0-9])[0-9][-.]([0-9]{2})[-.]([0-9]{2})[-.]([0-9]{2})[-.]([0-9]{2})$
One USA phone number, without any other information
  • +(33)1.55.85.91.17
  • 01.55.56.57.17
^(\([0-9]{3}\) |[0-9]{3}-)[0-9]{3}-[0-9]{4}$
One email, without any other information employeename@company.com
}^.+@[^\.].*\.[a-z]{2,}$
String limited to 15 characters abc123 @ & xyz
^.{1,15}$

Note: It is not advisable to apply this type of constraint on memo questions, where HTML code may be added when the text is formatted. When the constraint is being checked, the whole character string will be considered (the text entered as well as the HTML code).

example   If a user enters A bold text in a memo question, the character string considered is <strong>A bold text</strong> and the size of the string is 28 characters, not 11

Tags:
Powered by XWiki © EasyVista 2022