In a google sheet I am given a "userEmail" of the pattern: [email protected]
how can I extract only the last name using regex in google sheets? I managed to extract the first name via "\w " but can't get the lastname without any other characters.
I am completely new to regex with google sheets and hope to find some help.
Thanks in advance!
CodePudding user response:
Try
=REGEXEXTRACT(email,"\.(.*)@")
or for Germany
=REGEXEXTRACT(email;"\.(.*)@")
CodePudding user response:
Use
=REGEXEXTRACT(email,"\.([^@]*)@")
EXPLANATION
--------------------------------------------------------------------------------
\. '.'
--------------------------------------------------------------------------------
( group and capture to \1:
--------------------------------------------------------------------------------
[^@]* any character except: '@' (0 or more
times (matching the most amount
possible))
--------------------------------------------------------------------------------
) end of \1
--------------------------------------------------------------------------------
@ '@'
