SAP REGEX POSIX SIMPLE



Get Example source ABAP code based on a different SAP table
  



ABAP_POSIX_REGEX - Simplified Regular Expressions (obsolete)
In addition to the regular expressions in accordance with the extended POSIX standard IEEE 1003.1, the class CL_ABAP_REGEX also offers an alternative type of simplified regular expression with restricted functions. These simplified regular expressions (short: simplified expressions) do not support all POSIX operators and use partially different syntax. The semantics of regular expressions and simplified expressions are, however, the same.

Simplified Syntax
The following table provides an overview of the syntax differences between regular expressions and simplified regular expressions. Regular SyntaxSimplified Syntax ** +Not supported { } { } ( ) ( ) [ ][ ] |Not supported (?= ) (?! )Not supported (?: )Not supported
This table shows that many special characters in the regular syntax have no effect in the simplified syntax. Parentheses and curly brackets must be prefixed with the character if they are to keep their function in the regular syntax.



Latest notes:

Regular expressions with simplified syntax can only be used within the class CL_ABAP_REGEX. If the value 'X' is passed to the input parameter simple_regex, the regular expression is handled in accordance with the simplified syntax. By default, syntax in accordance with the extended POSIX standard is used. If the simplified syntax is to be used in the statements FIND or REPLACE, an object of the class CL_ABAP_REGEX must be passed.
The simplified syntax corresponds to the syntax of regular expressions in the command grep on Unix.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
This table shows the differences in parentheses between regular syntax and simplified syntax. The final two columns show examples that match the expressions in the first column, depending on the syntax used. PatternRegular SyntaxSimplified Syntax (.)a(a) (. )(a)a
ABAP_EXAMPLE_END


ABAP_EXAMPLE_VX5
The first search uses regular syntax and finds the first three letters aaa. The second search has simplified syntax, where + does not have any meaning as a special character and finds the substring a+ from offset 2.
ABEXA 01226
ABAP_EXAMPLE_END