What are regular expressions and how are they used?
The OCL operators regExpMatch and replaceRegex use regular expressions.
There is a lot of information on regular expressions on the internet. Here is an example of the article Regular expression in Wikipedia. A good implementation can also be found at the following link: http://www.regular-expressions.info/
In Vertec, the basic elements (., *, +, [, ], ^, $, –, \) can be used:
. |
Any single character. Example: h.t matches hat, hit, hot and hut. |
[ ] |
Any one of the characters in the brackets, or any of a range of characters separated by a hyphen (-).
Examples: |
[^] |
Any characters except for those after the caret “^”.
Example: |
^ |
The start of a line. |
$ |
The end of a line (not the line break characters). Use this for restricting matches to characters at the end of a line.
Example: |
* |
Matches zero or more of the preceding characters or expressions.
Example: |
+ |
Matches one or more of the preceding characters or expressions.
Example: |
\ |
Escapes the above expressions, so that they can be matched as literal characters. Hence, to match a literal “\,” you must use “\\”. |
|
Checks whether a phone number consists only of digits. Spaces and '-' are allowed.
|
|
Abbreviates the first name from the written name on the user (first name and last name are in the same field):
Result: John Doe > J. Doe |
|
Finds all users named Meier, Mayer, Mejer, Maier, Meyer etc.:
|
|
Displays accounts by accont name only what is in parentheses:
Result: Test company (additional information) > additional information |
|
Displays accounts by account name only what is not in parentheses:
Result: Test company (additional information) > Test company |