Bring your best ideas to the AI Use Case Contest! Enter to win 40 hours of expert engineering support and bring your vision to life using the powerful combination of Alteryx + AI. Learn more now, or go straight to the submission form.
Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Regex not working for name

Yuri24
8 - Asteroid

I am trying to convert name of a certain format to FirstName Lastname. My regex is not working for all scenarios.

 

Regex I am using is: ^(\w+).*?(\w+)$

Parsing into 2 names and concatenating them. However, this is not working for cases 1 and 4. 

 

Example: Trying to get Oscar Wilde from

Wilde, Oscar A.
Wilde, Oscar
Wilde Jr, Oscar
Wilde Jr, Oscar Senior
3 REPLIES 3
DanM
Alteryx Community Team
Alteryx Community Team

Because of the patterns you are suggesting, you probably won't be able to just use regex in this instance to parse everything exactly in one tool. I would suggest parsing it out first using the comma using the Text to Columns first. This would then allow you to complete the parsing using regex for both columns created no matter the pattern.

alexnajm
18 - Pollux
18 - Pollux

This expression works for these instances: ^(\w+)\s*\w*,\s(\w+).*$

 

In this case I might use the replace function in RegEx or a formula RegEx_Replace([field],"^(\w+)\s*\w*,\s(\w+).*$","$2 $1")

Yuri24
8 - Asteroid

Thanks!

Labels
Top Solution Authors