How to Implement Regular Expressions

A validation rule can be based on regular expression pattern matching. For example, you can do the following:
cim1265
A validation rule can be based on regular expression pattern matching. For example, you can do the following:
  • Specify a list of invalid characters or values for an attribute
  • Restrict the user from typing invalid constructs, such as an improperly formed DN or telephone number
The following JavaScript example enforces telephone number format as +nn nnn-nnn-nnnn:
phone=/\+\d{1,3} \d{3}-\d{3}-\d{4}/;
Wrap regular expressions defined in XML in CDATA, as in the following example:
<ValidationRule name="Phone pattern" description="+nn nnn-nnn-nnnn"
 messageid="4001">
   <RegularExpression>
      <![CDATA[ ((\+|\d)*+(\s*|\x2D))?\d\d\d-\d\d\d-\d\d\d\d]] > 
   </RegularExpression>
</ValidationRule>
Validation rules based on regular expressions must comply with the requirements defined in the java.util.regex package.