Get Example source ABAP code based on a different SAP table
ABAP_POSIX_REGEX - 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. ITOC
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.
ABAP_EXAMPLE_VX5 After replacement, text> contains the content Yeah Yeah Yeah! >. ABEXA 01215 ABAP_EXAMPLE_END
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.
ABAP_EXAMPLE_VX5 After replacement, text> has the content Roll'n'Rock>. ABEXA 01216 ABAP_EXAMPLE_END
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.
ABAP_EXAMPLE_VX5 After replacement, text> contains the content again and again>. ABEXA 01217 ABAP_EXAMPLE_END
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.
ABAP_EXAMPLE_VX5 After replacement, text> contains the content and again and >. ABEXA 01218 ABAP_EXAMPLE_END