54.5 GREP Function Signature 2
Returns the values of the input varchar2
that match a regular expression.
Syntax
APEX_STRING.GREP (
p_str IN VARCHAR2,
p_pattern IN VARCHAR2,
p_modifier IN VARCHAR2 DEFAULT NULL,
p_subexpression IN VARCHAR2 DEFAULT '0',
p_limit IN PLS_INTEGER DEFAULT NULL )
RETURN apex_t_varchar2;
Parameters
Parameters | Description |
---|---|
p_str |
The input varchar2 .
|
p_pattern |
The regular expression. |
p_modifier |
The regular expression modifier. |
p_subexpression |
The subexpression which should be returned. If null, return the complete table value. If 0 (the default), return the matched expression. If > 0, return the subexpression value. You can also pass a comma separated list of numbers, to get multiple subexpressions in the result. |
p_limit |
Limitation for the number of elements in the return table. If null (the default), there is no limit. |
Example
Collect and print key=value
definitions.
declare
l_plist apex_t_varchar2;
begin
l_plist := apex_string.grep (
p_str => 'define k1=v1'||chr(10)||
'define k2 = v2',
p_pattern => 'define\s+(\w+)\s*=\s*([^'||chr(10)||']*)',
p_modifier => 'i',
p_subexpression => '1,2' );
sys.dbms_output.put_line(apex_string.join(l_plist, ':'));
end;
-> k1:v1:k2:v2
Parent topic: APEX_STRING