SAP REGULAR EXPRESSIONS

Get Example source ABAP code based on a different SAP table
  

Warning: Undefined variable $prev in /customers/b/9/9/trailsap.com/httpd.www/sap-help/index.php on line 54
ARTICLE

Regular Expressions
ABAP supports extended regular expressions in accordance with POSIX standard 1003.2. Regular expressions can be used after the addition REGEX of the statements
FIND
REPLACE
as well as an argument of the following functions
count, count_...
contains_...
find, find_...
match
matches
replace
substring, substring_...
for searching and testing character strings. The classes
CL_ABAP_REGEX
CL_ABAP_MATCHER
permit object-oriented use of regular expressions.
A regular expression r is made up of literal characters and special characters in accordance with the syntax of regular expressions and represents a set of character strings. If text is a character string represented by r, we say that r matches text or that r fits text. Two (different) regular expressions match if they fit the same set of character strings.
If you apply a regular expression to a character string text as a search string, then you are searching for matches of the regular expression with substrings of text. In this case, special characters in the regular expression do not match characters, but instead match positions, thus influencing the type and number of occurrences. When you test character strings, you are checking whether the full content matches a pattern.

Notes
A regular expression can be syntactically correct, but too complex for execution, which then raises a handleable exception of the CX_SY_REGEX_TOO_COMPLEX class. Refer to Exceptions in Regular Expressions.
The example program DEMO_REGEX and its enhancement DEMO_REGEX_TOY enable you to test the search and replace functions by using regular expressions on texts.

Copyright Note
This software uses the Boost.Regex Library. Copyright (c) 1998-2004 Dr. John Maddock.