Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

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

More Regex for parsing names! Hooray!

JFurda
8 - Asteroid

I have a love-hate with RegEx. I acknowledge the power it has, but can't seem to crack this particular task. I am given a variety of formats for names and need to parse out and rejoin first and last only. 

 

Here's my expression: ^(\w+)\W?((?<=\W).+(?=\W))?\W?(\w+)?$
The only things I can't figure out are hyphenated last names and apostrophes.  

Here's my data: The "Full Name" column is my input and the rest are the output of my RegEx parse.

edit: My "Data" is just filler in a variety of first and last names. The actual names are all over the place and my company wouldn't allow be to share that data. I created 9 variations that I've seen in the actual data.

 

Full NameFirst NameMiddle NameLast Name
First LastFirst Last
First Middle LastFirstMiddleLast
First Last-LastFirstLastLast
First O'LastFirstOLast
First Middle Middle LastFirstMiddle MiddleLast
First Middle Last-LastFirstMiddle LastLast
First O'last-LastFirstO'lastLast
First Middle O'LastFirstMiddle OLast
First M LastFirstMLast

 

I know that the answer is likely in one of the hundred posts on this topic, but I just can't find it! Is anyone able to help? 

Thanks! 

12 REPLIES 12
JFurda
8 - Asteroid

@MarqueeCrew 

 

You're a lifesaver! I built a simple flow that omits the need for RegEx. I can also add in other considerations for salutation, attribution, etc. with additional formulas.

I had to make the Word Count variable an Integer, but the rest was simple! 

JFurda_0-1603828303940.png

JFurda_1-1603828391903.png

 

 

MarqueeCrew
20 - Arcturus
20 - Arcturus

@JFurda ,

 

Thanks for the feedback!  If you put this learning into practice, you'll be saving lives yourself here in the community.  Thanks for posting your solution for all to see.

 

Cheers,


Mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
atcodedog05
22 - Nova
22 - Nova

Hi @JFurda 

 

This was a great scenario with an amazing approach.

 

Great exposure 🙂

 

Cheers and Happy Analyzing 😀

Labels