This rule checks the input value against a specific regular expression to see if the patterns match. You can define a sequence of patterns by including them all in order in a matchAllPatterns element. You can also specify sub-patterns to exclude. The syntax for pattern is:
<pattern regex="regex_pattern"/> |
The parameter for pattern is:
regex – A regular expression to validate the input value against. See the Javadocs for java.util.regex for more information.
The pattern rule can be further customized by adding exceptFor rules that define patterns to exclude in the matching process. The syntax for exceptFor is:
<pattern regex="regex_pattern"/> <exceptFor regex="regex_pattern"/> </pattern> |
The parameter for exceptFor is:
regex – A regular expression to exclude from the pattern match. See the Javadocs for java.util.regex for more information.
The following sample checks the input value against the sequence of patterns to see if the input value might be an area code. These rules specify a pattern that matches three digits contained in parentheses, such as (310).
<matchAllPatterns> <pattern regex="regex="\("/> <pattern regex="regex="\[0-9]{3}"/> <pattern regex="regex="\)"/> </matchAllPatterns> |
The following sample checks the input value to see if its pattern is a series of three letters excluding THE and AND.
<pattern regex="[A-Z]{3}"> <exceptFor regex="regex="THE"/> <exceptFor regex="regex="AND"/> </matchAllPatterns> |