You are viewing the documentation for Blueriq 17. Documentation for other versions is available in our documentation directory.
Regexp
This validation type checks whether a string value is part of a specified set of strings. You can use this type to validate a string as a correct postal code format, telephone number or email address.
Syntax
<posRegExp><negRegExp>
posRegExp - The attribute value should satisfy this regular expression.
negRegExp - The attribute value should not satisfy this regular expression.
The following characters are allowed in these regular expressions:
^[0-9]{4}\s{0,1}(?)[a-zA-Z]{2}$
The regular expressions used in several Blueriq Encore functions are common Java 1.4 expressions. For a complete documentation we refer to the online java documentation.
When writing regular expressions, you should make sure that they do not make the system vulnerable to ReDos attacks. The system can give a denial of service when an evil expression is used, that takes very long to evaluate by the parser.
Examples of evil regular expressions:
- (a+)+
- ([a-zA-Z]+)*
- (a|aa)+
- (a|a?)+
- (.*a){x} | for x > 10
The above are suspectible to aaaaaaaaaaaaaaaaaaaaaaaa!
It is difficult to give general rules that make sure that your expression is not evil, and even recognizing them can be hard. When writing regular expressions, consider Atomic Groups which help to avoid the evil behavior.
Examples
Postal code
<^[0-9]{4}( ?)[a-zA-Z]{2}$>
Value | Result |
---|---|
“1000 AA” | valid |
“1000AA” | valid |
“10001AA” | invalid |
Telephone number
<(^\+[0-9]{2}|^\+[0-9]{2}\(0\)|^\(\+[0-9]{2}\)\(0\)|^00[0-9]{2}|^0)([0-9]{9}$|[0-9\-\s]{10}$)>
Value | Result |
---|---|
“010 1234567” | valid |
“+31(0)10 1234567” | valid |
“010-1234567” | valid |
“010 123456789” | invalid |
E-mail address
<^.+@[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4})$><(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)|\s>
Value | Result |
---|---|
“test@email.nl” | valid |
“test@email.failure” | invalid |
For more examples, you can check this website: http://www.regexlib.com/