with your_data as (
select 'RT @username: Stay behind, or take the jump (anything in text or tags and emoji)' as str
)
select regexp_extract(str,'^RT\\s(\\S*)\\s(.*)$',1) as username,
regexp_extract(str,'^RT\\s(\\S*)\\s(.*)$',2) as tweet
from your_data;
Результат:
OK
username tweet
@username: Stay behind, or take the jump (anything in text or tags and emoji)
Time taken: 1.092 seconds, Fetched: 1 row(s)
Используйте '^RT\\s(\\S*):\\s(.*)$'
, если вы не хотите использовать «:» в имени пользователя.
Или '^RT\\s(\\S*):?\\s(.*)$'
, если :
необязательно:
with your_data as (
select 'RT @username Stay behind, or take the jump (anything in text or tags and emoji)' as str
)
select regexp_extract(str,'^RT\\s(\\S*):?\\s(.*)$',1) as username,
regexp_extract(str,'^RT\\s(\\S*):?\\s(.*)$',2) as tweet
from your_data;
Результат:
OK
username tweet
@username Stay behind, or take the jump (anything in text or tags and emoji)
Time taken: 28.587 seconds, Fetched: 1 row(s)