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 Name | First Name | Middle Name | Last Name |
First Last | First | Last | |
First Middle Last | First | Middle | Last |
First Last-Last | First | Last | Last |
First O'Last | First | O | Last |
First Middle Middle Last | First | Middle Middle | Last |
First Middle Last-Last | First | Middle Last | Last |
First O'last-Last | First | O'last | Last |
First Middle O'Last | First | Middle O | Last |
First M Last | First | M | Last |
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!
Solved! Go to Solution.
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 ,
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
Hi @JFurda
This was a great scenario with an amazing approach.
Great exposure 🙂
Cheers and Happy Analyzing 😀