我正在嘗試使用 postgreSQL 從表中的 jason 列中獲取特定型別的字串。
這是字串片段,我試圖從中獲取每行的費率和 $ 金額(例如 CommentFOS 費率 $00.00)
Last 4 CommentsFOS rate $10.00 OT/HOL $20.00, AP rate $30.00 OT/HOL $40.00
這是我目前的查詢
select id,
regexp_matches(current_data->>'description', '..\w\/\w* \$[0-9] [\.]*[0-9]','g') as rates
from table;
我得到的輸出是這樣的
ID. rates
1 { OT/HOL $20.0}
1 { OT/HOL $40.0}
也試過這個查詢
select id,
regexp_matches(current_data->>'description', '\w*FOS \w* \$[0-9] [\.]*[0-9]','g') as rates
from table;
我從上面的 sql 得到的輸出是
ID. rates
1 { CommentsFOS rate $10.00}
但是,我期待這樣的輸出
ID. rates
1 { CommentsFOS rate $10.00}
1 { OT/HOL $20.00}
1 { AP rate $10.00}
1 { OT/HOL $40.00}
uj5u.com熱心網友回復:
您可以使用
\S (?:\s rate)?\s \$\d*\.?\d
請參閱
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/484233.html
標籤:正则表达式 PostgreSQL
