DB2 Scalar functions - REGEXP_INSTR
The REGEXP_INSTR scalar function returns the starting or ending position of the matched substring, depending on the value of the return_option argument.
The schema is SYSIBM.
If the string unit is specified as CODEUNITS16 or OCTETS, and the string unit of the source string is CODEUNITS32, an error is returned (SQLSTATE 428GC).
For more information, see "String units in built-in functions" in Character strings.
The result of the function is a large integer. If the pattern expression is found, the result is a number from 1 to n, where n is the actual length of the source string plus 1. The result value represents the position expressed in the string units used to process the function. If the pattern expression is not found and no argument is null, the result is 0.
If any argument of the REGEXP_INSTR function can be null, the result can be null. If any argument is null, the result is the null value.
SELECT REGEXP_INSTR('hello to you', '.o',1,1) FROM sysibm.sysdummy1
SELECT REGEXP_INSTR('hello to you', '.o',1,2) FROM sysibm.sysdummy1
SELECT REGEXP_INSTR('hello TO you', '(.o).', 1,3,1,'i',1) FROM sysibm.sysdummy1