In addition to the regular expressions according to the extended POSIX standard IEEE 1003.1, the class CL_ABAP_REGEX also offers an alternative type of simplified regular expressions with restricted functionality. These simplified regular expressions (also known as simplified expressions) do not support all POSIX operators and use a slightly varying syntax. The semantics of regular expressions and simplified expressions is, however, the same.
The following table provides an overview of the syntax differences between regular expressions and simplified regular expressions.
Regular syntax | Simplified syntax |
* | * |
+ | not supported |
{ } | \{ \} |
( ) | \( \) |
[ ] | [ ] |
| | not supported |
(?= ) (?! ) | not supported |
(?: ) | not supported |
Regular expressions with simplified syntax can only be used within the class CL_ABAP_REGEX. If the value 'X' is transferred for the input parameter simple_regex, the regular expression is viewed according to the simplified syntax. By default, the syntax is used according to the extended POSIX standard. If the simplified syntax is to be used in the statements FIND or REPLACE, an object must be transferred.
Regular expression | Simplified expression | Matches |
(.) | - | a |
- | (.) | (a) |
\(.\) | - | (a) |
- | \(.\) | a |
The following program determines all consecutive repeated double characters.