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

Simple regex to parse names

Scrumbled
5 - Atom

I have a list of names that needs to be parsed into first name and last name (and exclude the rest). It looks like this:

 

TURNER, JANICE F
VAN DUYN, TAYLOR
BREAULT, JASON D
LOOBY, CYNTHIA M
REILLY, SHAWNMARIE

 

So the first part of the string (last name) may contain a space but is always followed by a comma. The rest of the string may contain a middle initial, which I want to exclude. The result should look like this:

 

TURNER        JANICE
VAN DUYN     TAYLOR
BREAULT       JASON
LOOBY           CYNTHIA
REILLY           SHAWNMARIE

 

3 REPLIES 3
mst3k
11 - Bolide

technically you don't really need regex for this. you could do a substring from 0 to the findstring of "," within your string, that will get you the last name.

then another substring of everything AFTER the findstring of "," will be the first+middle.

from the new first+middle column, do a text to columns tool, with a space delimiter. we'll assume anywhere there's a space, it's separating first and middle name.

 

i got the regex to work too. i think substring/findstring is computationally easier on the machine, but either way works

Luke_C
17 - Castor

Hi @Scrumbled 

 

Here's two ways, one with regex and one with the text to columns tools:

 

Below is the regex I used, although there are definitely a number of ways to do it.

(.*),\s([[:alpha:]]+).*

 

Luke_C_0-1631652667746.png

 

 

Scrumbled
5 - Atom

I know this can be done using text to columns, but I was looking for a solution with fewer steps/tools--even though regex may be computationally more taxing.

 

Thanks to both of the respondents!

Labels