Search code examples
regexgoogle-sheetsunicodegoogle-sheets-formula

Google Spreadsheets Regex - Separating first name with latin characters


I have a column in Google Spreadsheets that have full names. It looks like this:

Full_name
Acacio Bernardo
Carlos Moraes
André da Silva

I need to make it look like this:

Full_name           First_name
Acacio Bernardo     Acacio
Carlos Moraes       Carlos
André da Silva      André

I'm using the following:

=regexextract(B1;"\w*")

It works fine for the first two names ("Acacio" and "Carlos"), however in the third one instead of "André" I'm getting "Andr". I noticed that this regex expression doesn't work with accents and latin characters.

I tried to apply the regex in this post however seems that google spreadsheets doesn't support it (I get straight to an error, couldn't even explore it a little further).

Can someone help?


Solution

  • Use \S (non-space characters class) instead of \w:

    =REGEXEXTRACT(A1, "\S+")
    

    Result:

    enter image description here