Alteryx Designer Desktop Discussions

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

Parse Employee Names with Different Formats

bridgethutter
7 - Meteor

Hello,

 

I have a number of employee names I am trying to parse into a standard format. I know no matter what, I need to parse at the first comma. And I am just trying to get rid of the middle initial at the end but not all names have it and some first names have a double name with either a space or - in between. I want it to end up as last name and first name, however I have so many different formats, I am having a hard time finding the right regex formula. 

 

Current:

Employee Name
HUNTER,BRIDGETT T

HUNTER WONDERLIN,BRIDGETT T

HUNTER-WONDERLIN,BRIDGETT

HUNTER,BRIDGETT LOUIS T

HUNTER, BRIDGETT-LOUIS T

HUNTER, BRIDGETT-LOUIS

 

Desired Outcome

 

HUNTER                                        BRIDGETT

HUNTER WONDERLIN                 BRIDGETT

HUNTER-WONDERLIN                 BRIDGETT

HUNTER                                        BRIDGETT LOUIS

HUNTER                                        BRIDGETT-LOUIS

HUNTER                                        BRIDGETT-LOUIS

 

Thanks!

Bridget

6 REPLIES 6
Emmanuel_G
13 - Pulsar

@bridgethutter 

 

Find in attachement an easy regex expression to do that.

 

Is it ok for you ?

 

Emmanuel_G_0-1665583888701.png

 

MarqueeCrew
20 - Arcturus
20 - Arcturus

@bridgethutter ,

 

I think that the ask is how to remove a SPACE followed by a single LETTER which is at the end of the string.

 

.*(\s\u) is how you find that group with regex.

 

Regex_Replace([Name],"(.*)(\s\u)",'$1')

 

But you might want to avoid RegEx and use:

 

IF Length(Getword([Name],CountWords([Name])-1)) = 1
	THEN left([Name],Length([Name])-2)
ELSE [Name]
ENDIF

 

Cheers,

 

Mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
DavidSkaife
13 - Pulsar

Hi @bridgethutter 

 

While it's not 100% regex here is a way of doing it using Text to Columns and Regex:

 

DavidSkaife_0-1665584322339.png

 

bridgethutter
7 - Meteor

Thank you all for the help! @DavidSkaife and @MarqueeCrew both solutions worked. 

bridgethutter
7 - Meteor

Hi @Emmanuel_G  !

 

Thank you so much for the response! This worked great for all of them except for double first names.

 

Again, thank you for your help!

 

Bridget

Emmanuel_G
13 - Pulsar

@bridgethutter 

 

Don't hesitate to mark answer as solution if it worked as it.

Labels