25.5 GREP Function Signature 3

Returns the values of the input clob that match a regular expression.

Syntax

grep (
   p_str           in clob,
   p_pattern       in varchar2,
   p_modifier      in varchar2    default null,
   p_subexpression in varchar2    default '0',
   p_limit         in pls_integer default null )
   return wwv_flow_t_varchar2;

Parameters

Table 25-5 GREP Function Signature 3 Parameters

Parameters Description

p_str

The input clob.

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 => to_clob('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