26.23 REGEXP Function
This function escapes characters that can change the context in a regular expression. It should be used to secure user input. The following list depicts ascii characters that the function escapes with a backslash (\):
\.^$*+-?()[]{|
Syntax
APEX_ESCAPE.REGEXP (
p_string IN VARCHAR2 )
Parameters
Parameter | Description |
---|---|
p_string |
Text to escape. |
Example
The following example ensures the special character "-" in "Mary-Ann" is escaped and ignored by the regular expression engine.
DECLARE
l_subscribers varchar2(4000) := 'Christina,Hilary,Mary-Ann,Joel';
l_name varchar2(4000) := 'Mary-Ann';
BEGIN
IF regexp_instr(l_subscribers,'(^|,)'|| apex_escape.regexp(l_name)||'($|,)')>0
THEN
sys.htp.p('found');
ELSE
sys.htp.p('not found')
END IF;
END
Parent topic: APEX_ESCAPE