Ansicht
Dokumentation

ABENREGEX_POSIX_REPLACE - REGEX POSIX REPLACE

ABENREGEX_POSIX_REPLACE - REGEX POSIX REPLACE

RFUMSV00 - Advance Return for Tax on Sales/Purchases   General Data in Customer Master  
This documentation is copyright by SAP AG.
SAP E-Book

- Replacement Patterns (obsolete)

In addition to searching, the replacement of substrings in character strings is the most important application of regular expressions. When replacing, the occurrences of a search, that is, the substrings that match a regular expression, are replaced by one or more different character strings. In ABAP, the replacement is implemented using regular expressions with the addition REGEX of the statement REPLACE.

In contrast to regular text replacements, when regular expressions are used, operators can be used in the replacement text that refer to the relevant occurrence.

Operators for Replacement Texts

The following operators can be specified in the replacement text. These operators consist of the special characters $, &, `, and ´. The special characters can be converted into literal characters by prefixing the escape character \ or by using the addition VERBATIM of the REPLACE statement, where the latter improves the performance.

Addressing the Full Occurrence

The operators $0 and $& can be specified in the replacement text as placeholders for the entire current occurrence.

After replacement, text contains the content "Yeah Yeah Yeah!".

Addressing the Registers of Subgroups

The operators $1, $2, $3, ... can be used in the replacement text as placeholders for the character strings stored in the registers of subgroups for the current occurrence. If the n-th subgroup is not available, or it was not supplied with a value in the match, the corresponding operator $n is replaced by the empty character string.

After replacement, text has the content "Roll'n'Rock".

Addressing the Text Before the Occurrence

The operator $` can be used in the replacement text as a placeholder in front of the current occurrence. If multiple occurrences are replaced using REPLACE ALL OCCURRENCES, $` contains the unchanged text from the beginning of the text to the start of the occurrence, for every occurrence.

After replacement, text contains the content "again and again".

Addressing the Text After the Occurrence

The operator $' can be used in the replacement text as a placeholder for the entire text after the current occurrence.

After replacement, text contains the content "and again and".






PERFORM Short Reference   CL_GUI_FRONTEND_SERVICES - Frontend Services  
This documentation is copyright by SAP AG.

Length: 3211 Date: 20240426 Time: 025638     sap01-206 ( 60 ms )