SAP PCRE ABEXA



Get Example source ABAP code based on a different SAP table
  



Find a PCRE Regular Expression
The example demonstrates how to search for a regular expression in PCRE syntax.

ABAP_SOURCE_CODE
DEMO CL_DEMO_FIND_PCRE

ABAP_DESCRIPTION
In the example, a line of text and a regular expression can be entered. The class searches the text line text for the first match of the search pattern defined in the regular expression regex and highlights this section in the result display. The search expects a PCRE regular expression and is case-sensitive. The statement FIND is used to search the statement, while the statement REPLACE is used to mark the result. Here, the operator $0 serves as a placeholder for the match in the replacement text.
The predefined example text is: Cathy's cat with the hat sat on Matt's mat.
and the predefined regular expression is: ( b.at b)
The regular expression describes a word consisting of three characters, where the first is any single character and the other two are at .
The case-sensitive search for the first occurrence finds the word cat.



Latest notes:

NON_V5_HINTS
The demonstration program DEMO_REGEX can be used to test regular expressions before using them in programs.
ABAP_HINT_END