单词和文本结尾之间的regex

4zcjmb1e  于 2021-08-09  发布在  Java
关注(0)|答案(1)|浏览(206)

我正在尝试编写一个正则表达式,将sql查询分解为更小的子查询。给出这样一个问题:

create unlogged table A 
AS 
SELECT significant_digits(round(SUM(value * avgweight)/SUM(avgweight)), 2) AS avgvalue, 
       significant_digits(sum(value),2) AS sumvalue, 
       R_state AS F_state, 
       NULL AS F_year, 
       R_county AS F_county, 
       R_candidate AS F_candidate 
FROM R0 
WHERE TRUE 
  AND R_candidate IS NOT NULL 
  AND R_county IS NOT NULL 
  AND R_state IS NOT NULL 
GROUP BY R_candidate, R_county, R_state 
UNION ALL 
SELECT significant_digits(round(SUM(value * avgweight)/SUM(avgweight)), 2) AS avgvalue, 
       significant_digits(sum(value),2) AS sumvalue, 
       NULL AS F_state, 
       NULL AS F_year, 
       NULL AS F_county, 
       R_candidate AS F_candidate 
FROM R0 
WHERE TRUE 
  AND R_candidate IS NOT NULL 
GROUP BY R_candidate

我希望能够从这个查询中提取每个select语句。我编写了一个基本的正则表达式,用于在select和union之间获取文本,但我正在努力解决如何在select和查询结束之间获取文本的问题。 "SELECT(.*?)UNION" 非常感谢您的帮助,谢谢!

h9vpoimq

h9vpoimq1#

(SELECT(.*?)UNION)|(SELECT.*) 这是我想要的

相关问题