Вы можете использовать regexp_extract
, чтобы сопоставлять слова до и после m2
и извлекать их отдельно.
with t as ( select "This is a great property right in front of the beach. The 50 m2 apartment is divided into a bedroom" as text)
select
regexp_extract(t.text , "(\\w+)\\s+m2", 1) as word_before,
regexp_extract(t.text , "m2\\s+(\\w+)", 1) as word_after
from t ;
+--------------+-------------+--+
| word_before | word_after |
+--------------+-------------+--+
| 50 | apartment |
+--------------+-------------+--+