GREP Function Signature 1

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

Syntax

grep (
   p_table         in apex_t_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

Table 32-3 GREP Function Signature 1 Parameters

Parameters Description

p_table

The input table.

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 basenames of sql files in input collection.

declare
    l_sqlfiles apex_t_varchar2;
begin
    l_sqlfiles := apex_string.grep (
                       p_table => apex_t_varchar2('a.html','b.sql', 'C.SQL'),
                       p_pattern => '(\w+)\.sql',
                       p_modifier => 'i',
                       p_subexpression => '1' );
    sys.dbms_output.put_line(apex_string.join(l_sqlfiles, ':'));
end;
-> b:C