User Tools

Site Tools


How to use regex and where to use it

How to use

You'll need to create a pattern:

  • [0-9]: A character between 0 and 9
  • [a-z]: A character between a and z. The same can be done with capitals
  • [0-9]*: will match only numerical values. The * is to repeat [0-9] unlimited
  • [a-z]{3}: will match exactly 3 times, you can replace the 3 with any number that you want.
  • [a-z]|[5]: will match if the character is between a and z or is the number 5
  • [“a”“b”]: will match if the character is a or b. You can add as many characters that you want.

Regex examples

  • ^[a-zA-Z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$
  • [+]\d{2}\s\d{3}\s\d{2}\s\d{2}\s\d{2} will match a phone number in the format +12 123 12 12

Where to use

  • Portal rules
  • Guest authentication
  • Registration forms
howto/use-regular-expressions.txt · Last modified: 2021/06/03 14:40 (external edit)