Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Processing Internal Data →  Character String and Byte String Processing →  Expressions and Functions for String Processing 

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

and also as an argument of the following functions

where they are used for searching in 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, this indicates that r matches text or that r fits text. Two (different) regular expressions match if they fit the same set of character strings.

If a regular expression is applied to a character string text as a search string, this indicates that a search for matches of the regular expression with substrings of text is intended. 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 character strings are tested, this involves checking whether the full content matches a pattern.

Other versions: 7.31 | 7.40 | 7.54


Notes

  • A regular expression can have correct syntax, but be too complex for to be executed. This raises a handleable exception of the class CX_SY_REGEX_TOO_COMPLEX. See Exceptions in Regular Expressions.

  • The example program DEMO_REGEX and its enhancement DEMO_REGEX_TOY makes it possible to test the search and replace functions by applying regular expressions to texts.

This software uses Version 1.31 of the Boost.Regex Library. Copyright (c) 1998-2003 Dr. John Maddock. Attributes of this standard not yet support in this version are listed here.

Continue

Syntax of Regular Expressions

Testing Regular Expressions

Exceptions in Regular Expressions

Regular Expressions