I came across this multi-list field restrictions to limit range(selection) using regex. I got few references to add basic validations. Both work fine.

Ref1: ^({[^}]+}\|?){0,5}$

Ref2: ^.{38,116}$

I'm looking to add regex which makes the user to select even no. items only.

Did anyone come across regex to handle custom validation at field level like this? I have added a custom field level validation rule in normal, but looking if there is any regex to handle this scenario. (Sitecore 8.2u3)

1 Answer 1


You can pretty much reuse the first regex, just instead of saying that you need 0-5 guids, you should say that you need 0 or more groups of 2 guids:


So in fact you use regex which says:

I want

  • a guid {[^}]+}
  • a pipe |
  • and another guid {[^}]+}
  • then maybe pipe |?

Everything is wrapped with ( and )* so you say that you want 0 or more of those groups above (change * to + if you need at least 2 guids to be selected.

And ^ and $ chars are at the beginning and at the end to make sure nothing is before or after.

You need to remember that this regex will not help you if your user starts playing with raw value of the field and enter value with is not pipe delimited guid list.

  • 1
    @SivaSankar missing square brackets added. All tested and works as expected now
    – Marek Musielak
    Commented Jul 27, 2017 at 11:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.