Fredrik Norling blogged yesterday about using Regular Expressions to validate in XPages (but also traditional Domino web development). There is one option for validating using regular expressions that Fredrik didn’t mention, and it’s well worth covering. Because although you can find a lot of regular expressions on the web, writing your own or modifying regular expressions can be challenging. And testing the regular expressions can be a slow and boring process. Wouldn’t it be great if you had a wizard to build them in Domino Designer? Wouldn’t it be great if you could test them from within Domino Designer?

Well, actually you can, thanks to those nice developers at IBM.

If you want to validate and throw errors client-side, you might want to use the Dojo Validation Text Box. If not, it’s still worth dropping a Dojo Validation Text Box on your XPage, just to be able to play about with and test your regular expressions in Designer. The Dojo Validation Text Box has a property called regExp. You can manually type the regular expression in, as with the validators. But things get really interesting when you launch the external property editor.

Regular Expressions Page 1

 

That first tab allows you to build up your regular expressions. You can select from predefined tokens such as “Any character”, “Alphanumeric character”, “Lower case”, then define the number of occurrences. The Add button allows you to build up a regular expression.

And if you find a regular expression online that you think is what you need, you can just type it into the “Current regular expression” box.

Click Next> and you can test the regular expression.

Regular Expressions Page 2

Enter sample text and while it fails to match your regular expression, you see the error message in the title bar. Once it matches, the warning message changes to an information message telling you “The text matches the regular expression”.

It’s almost enough to make you want to prefer regular expressions for validating text fields.

12 thoughts on “Test Your Regular Expressions In Domino Designer”

  1. Hello, thanks for the tip. I use the QuickREx plugin, good for testing the regular expression, but id does not have a wizard…

    1. I believe that the editor itself is an Eclipse plugin and was not specifically designed for the Extension Library. It’s surfaced in the Dojo Validation Text Box, which is part of the Extension Library, available either in Upgrade Pack 1 for 8.5.3 or the OpenNTF project at http://extlib.openntf.org. I suspect you’ll need 8.5.3 as a minimum. I think the editor was added into the Domino Designer tooling later on in the evolution of the Extension Library. In future releases it may get added back into the other controls that support regular expression validators.

  2. For those asking where to find it, it’s currently (8.5.3) only available on the Dojo Validation Text Box control, on the All Properties tab, on the regexp property.

    Because it’s just an Eclipse editor, it may well get added back into other controls where appropriate in further releases.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.