Starting from the 2013 R2 the regular expression is supported on entry-field control. The power of regular expression is now available also during entry-field accept. The following example shows how to declare regular expression on a screen section entry-field:
03 e1 entry-field line 2 col 2 size 50 value var
validation-regexp "^w+[w-.]*@w+((-w+)|(w*)).[a-z]{2,3}$"
validation-errmsg "Invalid email address"
validation-opts 7.
Due to the above code, if the entry-field content doesn't match with the regexp specified by validation-regexp, then the message specified by validation-errmsg is automatically shown by the runtime and the focus is kept on the field. validation-opts=1 means that the check is done case insensitive
Matches bob-smith@foo.com | bob.smith@foo.com | bob_smith@foo.com
Non-Matches -smith@foo.com | .smith@foo.com | smith@foo_com
The regexp syntax must respect Java specifications
http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html.
Regular Expression are collected and discussed on the web. For example, on this web site http://regexlib.com/ you can find ready-to-use expression for common issues as well as an online regexp validator tool.
|