Henri Chevallier
Henri Chevallier

Reputation: 11

Extract multiple twitter handles in google sheet cell

I'm trying to extract multiple twitter handles in a google sheet, like that :

Lorem Lorem Lorem @Handle1 Lorem Lorem Lorem Lorem Lorem Lorem
Lorem Lorem LoremLorem Lorem Lorem @Handle2 Lorem Lorem Lorem @Handle3

What i want (extracted in the same cell) :

@Handle1
@Handle2
@Handle3

How i can do ?

Cheers

Upvotes: 1

Views: 104

Answers (3)

player0
player0

Reputation: 1

=JOIN(CHAR(10), QUERY(TRANSPOSE(SPLIT(A1," ")), 
 "select Col1 where Col1 contains '@'", 0))

Upvotes: 0

player0
player0

Reputation: 1

=REGEXEXTRACT(A1, "(@\w*)")&" "&JOIN(" ", REGEXEXTRACT(A1, "(@\w*).*(@\w*)"))


=REGEXEXTRACT(A1, "(@\w*)")&CHAR(10)&JOIN(CHAR(10), REGEXEXTRACT(A1, "(@\w*).*(@\w*)"))

Upvotes: 0

Jan
Jan

Reputation: 43189

You could use

@\w+

See a demo on regex101.com.


Broken down, this says

@\w+      # @-sign + word characters

Lookarounds seem not to be supported by re2 (see here for more information).

Upvotes: 0

Related Questions