Whoopcg
Whoopcg

Reputation: 131

Google Sheets extract string between strings

So, I've imported emails to google sheets and I'm trying to extract some info.

e.g.: "Bla Bla Bla Ref: 338256 Clients: André Paulos, Beatriz Silva Thank you" To retrieve the value of "Ref" I'm using: =ArrayFormula(REGEXEXTRACT(A2:A,"[\n\r].Ref: \s([^Clients]*)"))

If I use the same for extracting Clients' names, I get the results with a lot of missing characters. For the above example, it returns "André P". (Using: =ArrayFormula(REGEXEXTRACT(A2:A,"[\n\r].Clients: \s([^Thank*)"))

What am I missing? Thanks in advance

Upvotes: 0

Views: 462

Answers (1)

JPV
JPV

Reputation: 27302

See if this helps

 =Arrayformula(if(len(A2:A), trim(regexextract(A2:A, "([^\:]*),")),))

or

=Arrayformula(if(len(A2:A), regexextract(A2:A, "Clients: (.*),")),))

Upvotes: 2

Related Questions