SAP MATCHES FUNCTIONS



Get Example source ABAP code based on a different SAP table
  


• matches ABAP_FUNCTION

ABAP_RELEXP - matches

ABAP_SYNTAX
... matches( val = text pcre$|xpath = regex $[ case = case$]
$[off = off$] $[len = len$] ) ...

What does it do?
The built-in predicate function matches compares a search range of the argument text, defined using off and len, with the regular expression specified in regex.
If the argument pcre is used, regex must contain a PCRE regular expression.
If the argument xpath is used, regex must contain a XPath regular expression.
A regular expression in PCRE or XPath syntax is compiled in an extended mode: Most unescaped whitespace (blanks and line breaks) of the pattern are ignored outside character classes and comments can be placed behind #. In order to specify whitespace and # in a pattern, they must be escaped or the extended mode must be switched of with (?-x) in the regular expression.
The function returns a truth value.
The return value is true when the whole search range matches the regular expression.
It is false else.
The comparison is case-sensitive by default, but this can be overridden using the parameter case.



Latest notes:

The match function match can be used to return a substring that matches a regular expression.
Besides pcre and xpath, the obsolete argument regex can also be used. Then an obsolete POSIX regular expression must be passed.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
The first predicate function returns the value true because the argument val only contains letters. The second predicate function returns the value false because the argument val also contains numbers.
ABEXA 01123
ABAP_EXAMPLE_END

ABAP_EXAMPLE_ABEXA
Predicate Function, matches
ABAP_EXAMPLE_END



Runtime Exceptions



Catchable Exceptions
CX_SY_RANGE_OUT_OF_BOUNDS
Reason for error:
Illegal offset or length specified in off and len.
Runtime error:
STRING_OFFSET_TOO_LARGE
CX_SY_REGEX_TOO_COMPLEX
Reason for error:
See Exceptions in Regular Expressions.
Runtime error:
REGEX_TOO_COMPLEX
CX_SY_STRG_PAR_VAL
Reason for error:
Regular expression in regex is empty.
Runtime error:
STRG_ILLEGAL_PAR