Skip to content

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

match - Match Function

The match function returns a subfield of a character-like argument that matches a regular expression.

Other versions: 7.31 | 7.40 | 7.54

Syntax


... match( val = text
regex = regex [
case = case] [occ = occ] ) ...

Effect

The match function scans text for the matches (specified in occ) with the regular expression (specified in regex) and returns the substring found. The search is case-sensitive by default, but this can be overridden using the parameter case.

The return code has the type string.


Example

The following match function returns x2.

cl_demo_output=>display( 
  match( val = 'x1 x2 x3' regex = 'x.' occ = 2 ) ).

Executable Example

String Functions, count, find and match

Exceptions

Handleable Exceptions

CX_SY_REGEX_TOO_COMPLEX

CX_SY_STRG_PAR_VAL

  • Cause: Regular expression in regex is empty or there are 0 occurrences in occ.
    Runtime error: STRG_ILLEGAL_PAR