Regexp_Substr is a scalar function which returns one occurrence of a substring that matches the regular expression pattern.

Syntax :

Regexp_Substr(source_string, pattern_expression, start, occurence, flags, group)

 

Example : Return the string which matches any character preceding a ‘a’.

select regexp_substr(‘Today is mother’s day’, ‘.a’,1,1)

from sysibm.sysdummy1

Result : ‘da’