Skip to main content

Cookie control banner

Necessary Cookies
These cookies are necessary for this website to function correctly. They are set when you perform certain actions on the site, such as creating an account, logging in, changing your privacy preferences or submitting a form. You can block these cookies in your browser, but this will stop parts of the site from working properly.
Functional Cookies
These cookies allow the website to provide extra functionality and more personalised experiences. They may be set by us or by third party providers whose services we have added to our pages. If you choose not to allow these cookies, these services may not work correctly.
Analytical Cookies
These cookies record anonymous data on how visitors use our website to help us monitor how well our website works. This data includes how many people have looked at specific pages, how long visitors stay on the site, and what devices they use. We use this data to identify changes that we could make to improve your experience and make our website more efficient.
Marketing Cookies
We set some cookies so you are shown more relevant marketing content. These include cookies from third-party advertising networks to show you different adverts on their services if you have previously visited our site. If you choose not to allow these cookies, you may experience less relevant advertising on other sites.
Browse Documentation

Use pattern matching to validate fields

Created by Contensis product team, last modified by j.moore on 19 May 2021

The matches pattern validation method ensures that the value of a field matches a specific pattern defined by a regular expression.

A regular expression is a special text string for describing a search pattern. We use these expressions to validate the text that an author enters into a field of an entry.


An email field with an email pattern matching validation showing an error
An example of a text field with an email address regular expression validation applied.

How to set the validation

With a content type open for editing:

  1. Select the text field you want to set a validation rule for and pick the Validation tab from the Field Settings panel.
  2. Choose the required regular expression pattern you want to use from the Matches pattern dropdown, or define your own using the Custom option.
  3. You can add an alternative validation message by entering it in the Validation message text box. This will be displayed if the field fails validation when published.

Setting a custom expression

You can use the Custom option in the matches pattern dropdown to create your own. Using a handy library and expression checker, like Regular Expression 101, to test your expression makes things easier.

Note: Expressions need to be written using the full JavaScript syntax to be valid.

Predefined regular expressions

We've included some predefined expressions covering some standard scenarios.

Website address

Allowed values Disallowed values name@zengenti

Email address

Allowed values Disallowed values

UK postcodes

Allowed values Disallowed values
sy83eg sy8-3eg
SY83EG sy8 £eg

12 hour time

Allowed values Disallowed values
10:20 am 12:15
10.42.01 AM 101603
09 26 03 PM 12am
7:35 PM 10:67

24 hour time

Allowed values Disallowed values
10:20 1215
10.42.01 101603
09 26 03 12 am
07:57 10:67

Title casing

Allowed values Disallowed values
This Is A Title This is a title
This Is Another Title This is A title