Start page
Start page

Start page / Template development / Rules / Comparative expressions / <MATCHES/> tag

<MATCHES/> Validation with regular expressions

The <MATCHES/> tag can be used in the value determination area of the rule definition (or for the definition of a precondition) and is used to enter a regular expression in a rule.

A comparison value that refers to a particular property of the form element (such as the value of the input component) or even of the form (“In which language should the form be opened?”) must be specified in the <MATCHES/> tag. To do this, a <PROPERTY/> tag must be entered within the <MATCHES/> section.

If the comparison value fulfills the conditions of the regular expression, the <MATCHES/> section returns TRUE; if not, it returns FALSE.

"regex" attribute

The regular expression is passed via the “regex” attribute. Depending on the regular expression, certain characters, strings and sequences of characters occurring in the comparison value are reviewed and evaluated.

<MATCHES regex="ABC" />

Examples

1. Language-dependent validation

In the following example, only a certain branch of the rule is carried out depending on the editing language currently being processed. The “st_standard” input component, for which the rule is defined, permits the language-dependent specification of a DIN standard (for German (“DE”)) or an ISO standard (for English (“EN”)). Using the definition of a precondition, the rule checks the language in which the form is being edited by the editor (language-dependent validation).

A different regular expression is defined within the rule for both languages. The expression checks whether the editor's input is valid for this language.

<RULES>

<ON_SAVE>
<IF>
<EQUAL>
<PROPERTY source="#global" name="LANG"/>
<TEXT>DE</TEXT>
</EQUAL>
</IF>
<WITH>
<MATCHES regex="^DIN\ \d\d*$">
<PROPERTY source="st_standard" name="VALUE"/>
</MATCHES>
</WITH>
<DO>
<VALIDATION>
<PROPERTY source="st_standard" name="VALID"/>
<MESSAGE lang="*" text="No DIN standard given"/>
<MESSAGE lang="DE" text="Keine DIN-Norm angegeben"/>
</VALIDATION>
</DO>
</ON_SAVE>

<ON_SAVE>
<IF>
<NOT>
<EQUAL>
<PROPERTY source="#global" name="LANG"/>
<TEXT>DE</TEXT>
</EQUAL>
</NOT>
</IF>
<WITH>
<MATCHES regex="^ISO\ \d\d*$">
<PROPERTY source="st_standard" name="VALUE"/>
</MATCHES>
</WITH>
<DO>
<VALIDATION>
<PROPERTY source="st_standard" name="VALID"/>
<MESSAGE lang="*" text="No ISO standard given"/>
<MESSAGE lang="DE" text="Keine ISO-Norm angegeben"/>
</VALIDATION>
</DO>
</ON_SAVE>

</RULES>

© 2005 - 2015 e-Spirit AG | All rights reserved. | Last change: 2013-12-09