postgresql数组过滤器,支持正则表达式
create or replace function array_filter(arr1 text[],filterstr text) returns text[]
language plpgsql immutable as $D$
-- 去除符合某模式的元素
declare i text;
arr text[];
begin
if $1 is null then return null; end if;
FOREACH i IN ARRAY $1
LOOP
if i !~ $2
then arr:=array_append(arr,i);
end if;
END LOOP;
return arr;
end;
$D$;