(?:from|join) [ \r\n\t]{0,}([a-z._]{0,}) ?: begin non-capturing group Выделенная группа не будет учитываться ... пример получения всех таблиц из накопленной статистики запросов with t1 as ( select queryid, calls, lower(query) as full_query, replace((regexp_matches(lower(query), '(?: from | join | lateral )[ \r\n\t]{0,}(["a-z0-9._]{0,})','gm'))[1],'"','') as foundedfulltable from pg_stat_statements where lower(query) not like '%function%' ) , t2 as ( select queryid, calls, regexp_replace(full_query, E'[\\n\\r\\t\\u2028]+', ' ', 'gm' ) as full_query, foundedfulltable ,case when strpos(foundedfulltable,'.')>0 then (regexp_match(foundedfulltable, '([a-z_]{1,})\.{1}(?:[a-z0-9_]{1,})'))[1] else null end as foundedschema ,case when strpos(foundedfulltable,'.')>0 then (regexp_match(foundedfulltable, '(?:[a-z_]{1,})\.{1}([a-z0-9_]{1,})'))[1] else foundedfulltab...