Skip to main content

Fixing regex for lastname that contain two words

  • June 15, 2022
  • 0 replies
  • 4 views

Forum|alt.badge.img+7

Hello everyone,

I’m trying to separate firstname and lastname using formulas I found online.
My issue is that some french name are like: John De Doe

The first word is always the firstname, the rest is the lastname.

I have this formula for firstname:
IF({Nom complet}, REGEX_EXTRACT({Nom complet}, ".* "))

And I have this formula for lastname:
IF({Nom complet}, REGEX_EXTRACT({Nom complet}, "\\s(.*)"))

It outputs “John De” as firstname instead of “John”.
and “De Doe” as lastname which is what I want.

I need a formula to get first word (preferably using regex) that works with special characters.

Thank you for your help,
Joachim