如何在 SQL Bigquery 中提取字符串、数字(来自长的自由文本)

How to EXTRACT string, numeric (from a long free text) in SQL Bigquery

我在 Bigquery SQL 中有一个列 audit_changes。那么如何在另一列中提取数字 'shipment_id' = '28149' 呢?顺便说一句,自由文本有另一个数字(ops_shipment_id),因此在提取 'shipment_id'.

时可能会出错

---\nshipment_id: 28149\ninvoice_number: \nremarks: \nother_type: \nsubmitter_id: \ntax_percent: \ninput_invoice_number: \noutput_invoice_number: \naccountant_notes: \npayment_status: false\nno_tax_on_customer: \nvat_included: false\ntolls: \nfuel_prices: \ndriver_type: \nis_locked: false\nrequest_payment_time: \nreject_payment_reason: \nop_ic_id: \nreceived_shipment_photo: false\naccountant_id: \nupdate_payment_status_time: \nprice_locked: false\nassign_ac_id: \nops_shipment_id: 16735\ncancellation_fee: \nactual_pickup_addr: \nactual_dropoff_addr: \n

您可以使用 regexp_extract():

select regexp_extract(str, '\nshipment_id: ([0-9]+)') as shipment_id