Hi All,
I am trying to use the regexp_substr function in TD14 (Version 14.00.00.01).
I want to be able to return a specified group result (in the simple example below, I expect 'Alex' to be returned, specified by the subexpr_arg being set to 1. (i.e. $1)select 'Alex 1Alex, Geddy 2Lee, Neil 3Peart' as thesql
,regexp_substr( thesql -- source_string
,'(\w+)\s+([0-9]+)\1' -- regexp_string
,1 -- position_arg
,1 -- occurrence_arg
,'i' -- match_arg (Ignore case)
,1 -- subexpr_arg
) as theresult;
According to the TD14 Manual (Page 786 of the SQL Functions, Operators, Expressions, and Predicates manual) indicates to me that this should work.
Subexpr_arg is defined as "a numeric argument (a nonnegative integer from 0 through 9). subexpr_arg indicates the subexpression in the pattern that REGEXP_SUBSTR is to return."
However, upon closer examination of the TD_SYSFNLIB database contents, I can't see an overload of the function that will let this syntax be used:
I can see the following function defintions:REPLACE FUNCTION "TD_SYSFNLIB"."REGEXP_SUBSTR" (
"source" /*Data Type Not Available*/,
"pattern" /*Data Type Not Available*/)
RETURNS /*Data Type Not Available*/
SPECIFIC "regexp_substr2"
LANGUAGE C
NO SQL
PARAMETER STYLE I
DETERMINISTIC
CALLED ON NULL INPUT
EXTERNAL
;
REPLACE FUNCTION "TD_SYSFNLIB"."REGEXP_SUBSTR" (
"source" /*Data Type Not Available*/,
"pattern" /*Data Type Not Available*/,
"startPosition" NUMBER(*),
"occurrence" NUMBER(*))
RETURNS /*Data Type Not Available*/
SPECIFIC "regexp_substr4"
LANGUAGE C
NO SQL
PARAMETER STYLE I
DETERMINISTIC
CALLED ON NULL INPUT
EXTERNAL
;
REPLACE FUNCTION "TD_SYSFNLIB"."REGEXP_SUBSTR" (
"source" /*Data Type Not Available*/,
"pattern" /*Data Type Not Available*/,
"startPosition" NUMBER(*))
RETURNS /*Data Type Not Available*/
SPECIFIC "regexp_substr3"
LANGUAGE C
NO SQL
PARAMETER STYLE I
DETERMINISTIC
CALLED ON NULL INPUT
EXTERNAL
;
AndREPLACE FUNCTION "TD_SYSFNLIB"."REGEXP_SUBSTR" (
"source" /*Data Type Not Available*/,
"pattern" /*Data Type Not Available*/,
"startPosition" NUMBER(*),
"occurrence" NUMBER(*),
"matchOption" /*Data Type Not Available*/)
RETURNS /*Data Type Not Available*/
SPECIFIC "regexp_substr"
LANGUAGE C
NO SQL
PARAMETER STYLE I
DETERMINISTIC
CALLED ON NULL INPUT
EXTERNAL
;
Also, the following query returns no rows:select *
from dbc.columns
where databasename = 'TD_SYSFNLIB'
and tablename = 'REGEXP_SUBSTR'
and columnname = 'subexpr_arg';
So, subexpr_arg does not exist as a parameter in the function in TD_SYSFNLILB.
Has anyone successfully used the regexp_substr function in TD14 to return a group (subexpr_arg) result?
Forums: