SAP REGEX SYSTEM CLASSES



Get Example source ABAP code based on a different SAP table
  


VERSION 5 IN
• CL_ABAP_REGEX ABAP_CLASS
• CL_ABAP_MATCHER ABAP_CLASS

ABAP_REGEX - System Classes
The system classes for regular expressions are CL_ABAP_REGEX and CL_ABAP_MATCHER. Both are documented in the class library.
ITOC

CL_ABAP_REGEX
Factory methods of class CL_ABAP_REGEX create an object-oriented representation of a regular expression passed in a character-like field:
CREATE_PCRE creates instances for regular expressions with PCRE syntax.
CREATE_XPATH2 creates instances for regular expressions with XPath syntax.
CREATE_XSD creates instances for regular expressions with XSD syntax.
CREATE_POSIX creates instances for regular expressions with POSIX syntax (obsolete).
Optional parameters allow further specifications for handling the regular expression:
The Parameter EXTENDED for CREATE_PCRE and CREATE_XPATH2 switches the extended mode for compiling PCRE and XPath expressions. The default value is ABAP_TRUE. In the extended mode, most unescaped whitespace (blanks and line breaks) of the pattern are ignored outside character classes and comments can be placed behind #. In order to include whitespace and # into a pattern, they must be escaped The extended mode can also be switched of with (?-x) in the regular expression.
The Parameter UNICODE_HANDLING for CREATE_PCRE and CREATE_XPATH2 defines how characters from the surrogate area are handled.
Instances of CL_ABAP_REGEX can be used with the class CL_ABAP_MATCHER and with the addition REGEX of the statements FIND and REPLACE .



Latest notes:

The class CL_ABAP_REGEX can also be instantiated with the operator NEW or the statement CREATE OBJECT, but this is deprecated. Such a direct instantiation of CL_ABAP_REGEX creates instances for regular expressions with POSIX syntax. Instead of direct instantiation, the above factory methods CREATE_PCRE, CREATE_POSIX, CREATE_XPATH2 or CREATE_XSD should be used.
Instances of CL_ABAP_REGEX for all kinds of regular expressions, PCRE, XPath, XSD and POSIX (obsolete) can be used with the addition REGEX of the statements FIND and REPLACE. This circumvents the restriction that regular expressions of XPath and XSD syntax cannot be specified directly as character strings.
Instances of CL_ABAP_REGEX cannot be used with the addition PCRE of the statements FIND and REPLACE.