Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Free Trial

Alteryx Designer Desktop Discussions

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

Parsing Name with RegEx

alexg1
8 - Asteroid

Hello everyone,

 

I've got a list of names that are stored like so in a dataset:

 

     JohnAdams

 

And I need to parse them to get this:

 

     John Adams

 

The names are variable in length, so I do not know of a formula that would accomplish this result. The First and Last names are all correctly capitalized, so if there is a way to parse by case, I think that would work.

 

Thank you for your time

2 REPLIES 2
JohnJPS
15 - Aurora

Hi @alexg1,

 

Try a Formula tool with the following:

 

REGEX_Replace([f1], "([a-z])([A-Z])", "$1 $2", 0)

 

...where [f1] is the field in question.

 

Explanation:

Parentheses in a RegEx will "mark" any match, and these are counted starting at 1.

With this expression, we therefore match any lower-case letter, which is $1, followed by any capital letter, which is $2.

That match will be replaced by $1, a space, then $2... giving you the space you wanted.

The final 0 argument at the end tells Alteryx to respect the case of the input; (ignoreCase = 0 or false)

 

Hope that helps!

John

 

alexg1
8 - Asteroid

That worked perfectly, thank you! I appreciate you going through the underlying logic as well, RegEx syntax is a bit daunting for neophytes!

Labels
Top Solution Authors