Regex

Hello everyone,

I am looking for information on the Regex to configure in the strategies.

Do you have links to docs or tutorials?

For example, I would like to check on a form field that the value entered complies with this: Must begin by 4 letters in uppercase followed by 2 numbers.

Thanks for your help

Gégé

Top Replies

  • Hi  

    To validate the value of a property/attribute, you'll want to use a Administration Policy adding a "Property Generation and Validation" rule

    Select the object property to contr…

  • Hi  

    To validate the value of a property/attribute, you'll want to use a Administration Policy adding a "Property Generation and Validation" rule

    Select the object property to control

    Then for a RegEx, select the '<object property>' must match regular expression <value> option.

    In the case you're looking at, you need a two part expression, 

    1) Checking for the first 4 characters being upper case between A and Z

    ([A-Z]{4})

    2) check that the new 2 characters are numbers between 0 and 9

    ([0-9]{2})

    Joining these together gives you an expression which checks if there is an occurance of 4 upper case characters followed by 2 numbers anywhere in the string

    ([A-Z]{4})([0-9]{2})

    For example, the below shows that aABCD12s is valid, as it contains ABCD12 which meets the RegEx.

    To modify this so that the match must be at the start of the string, you prefix with ^, and to say it must match at the end, you suffix with $. Adding both the prefix and suffix, means that the bit in the middle has to be exact...

    ^([A-Z]{4})([0-9]{2})$

    However with the latest RegEx (with the prefix and suffix), the same value is not allowed:

    Setting it to be just ABCD12, is allowed as it meets the RegEx express

    There are a number of websites that can guide you through Regular Express (a web search for "Regular Express Tester" or "RegEx Tester" will provide a number of results where you can read up on RegEx and test them on their web pages, IE

    RegExr: Learn, Build, &Test RegEx

    regex101: build, test, and debug regex

    However there are many sites out there explaining regular express.

    The above sites give you "Quick Reference" / "Cheat sheets" to get you started