Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Program Flow Logic →  Expressions and Functions for Conditions →  log_exp - Logical Expressions →  rel_exp - Predicates →  rel_exp - Predicate Functions →  Predicate functions for character-like arguments 

rel_exp - matches, Predicate Function

Other versions: 7.31 | 7.40 | 7.54


... matches( val = text
regex = regex [case = case] 
             [off = off] [len = len] ) ...


The predicate function matches compares a search range of the argument text, defined using off and len, with the regular expression specified in regex. A corresponding truth value is returned. The return value is true when the whole search range matches the regular expression. The comparison is case-sensitive by default, but this can be overridden using the parameter case.


The match function match can be used to return a substring that matches a regular expression.


The first predicate function returns the value "true" because the argument val only contains letters. The first predicate function returns the value "false" because the argument val also contains numbers.

ASSERT     matches( val = 'abcde' regex = '[[:alpha:]]*' ). 
ASSERT NOT matches( val = 'a123e' regex = '[[:alpha:]]*' ).

Executable Example

Predicate Function, matches


Handleable Exceptions


  • Cause: Illegal offset or length specified in off and len.
    Runtime error: STRING_OFFSET_TOO_LARGE



  • Cause: Regular expression in regex is empty.
    Runtime error: STRG_ILLEGAL_PAR