Created
April 4, 2023 06:31
-
-
Save jianhe-fun/d4afee9bc4d485a253c129df38e8632d to your computer and use it in GitHub Desktop.
escape_regular_expression.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
https://stackoverflow.com/questions/5144036/escape-function-for-regular-expression-or-like-patterns/45741630#45741630 | |
escape regular expression. | |
*/ | |
CREATE OR REPLACE FUNCTION public.f_regexp_escape(text) | |
RETURNS text | |
LANGUAGE sql | |
IMMUTABLE PARALLEL SAFE STRICT | |
AS $function$ | |
select regexp_replace($1,'([!$()*+.:<=>?[\\\]^{|}-])','\\\1','g') | |
$function$; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment