psql=# drop operator if exists =~ (text, text); psql=# drop function if exists pcre_match (text, text); psql=# create function pcre_match (text, text) returns bool language plperl immutable leakproof strict parallel safe as $$ return $_[0] =~ $_[1] ? 1 : 0; $$; psql=# create operator =~ (function = pcre_match, leftarg = text, rightarg = text); my @items = getfromdb ("select id, text from table where text =~ '$kwre'");