GSUB与Postgres

时间:2017-08-17 18:58:40

标签: sql postgresql

我如何编辑下面的备忘录,以便在第一组数字后删除QPC CANCEL以及以下字母和数字?

输入:

Memo field: QPC CANCEL 861518069 CONV. TO Test Receipt 1430
Memo field: QPC CANCEL 8615315362 Another test transaction
Memo field: QPC CANCEL 86151343 Our third test transaction

输出:

Memo field: 861518069
Memo field: 8615315362
Memo field: 86151343

1 个答案:

答案 0 :(得分:0)

with t(col) as(
values
('Memo field: QPC CANCEL 861518069 CONV. TO Test Receipt 1430'),
('Memo field: QPC CANCEL 8615315362 Another test transaction'),
('Memo field: QPC CANCEL 86151343 Our third test transaction')
)

select substring(col from 'QPC CANCEL\s*(\d+)' ) from t