Jaskeil
Jaskeil

Reputation: 1232

How to extract everything after parentheses in BigQuery?

How can I extract all the characters after the first word?

For example, I would like to have (084M) in its own column with the parentheses included. I've tried to SPLIT and REGEXP_EXTRACT but I have ran into issues.

Table:

Name
Elizabeth (084M)
Elizabeth (084M)
Elizabeth (084M)
Pittston (14KN)
Pittston (14KN)
Pittston (14KN)
Cheektowaga (14ON)

Image of Table:
enter image description here

Upvotes: 0

Views: 964

Answers (2)

Vibhor Gupta
Vibhor Gupta

Reputation: 709

Try below :

select *,
  SPLIT(name, ' ')[OFFSET(1)]
  from data

Upvotes: 0

Mikhail Berlyant
Mikhail Berlyant

Reputation: 173210

use below

select *,
  regexp_extract(name, r'\w+\s+(.+)')
from your_table

Upvotes: 1

Related Questions