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

Alteryx Designer Desktop Discussions

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

Regex Parse splitting incorrectly

mekopf
6 - Meteoroid

I am using the regex tool to parse a string instead of using the split tool because the delimiter has to be a space and a hyphen (hyphens can be used later in the string without a space so it has to include the space to be a delimiter): Here is the regex that I am using

 

^(.*)-\s(.*)-\s(.*)$

 

Most of the time it works, but about 5 out of 200 are not parsing correctly. I attached a small sample with the labels replaced of the input and output that I am getting.

 

Any thoughts on why it would not be parsing in these few instances would be welcomed!

 

 

4 REPLIES 4
Thableaus
17 - Castor
17 - Castor

Hi @mekopf 

 

When I try with your example, I get exactly what you expect.


I can imagine something is going on with your LABEL names that you're actually changed to generic names.

 

Would you have an example of these ones so we can analyze the string itself? Cause I'm pretty sure that this is the issue.

 

Cheers,

Thableaus
17 - Castor
17 - Castor

@mekopf 

 

One of my guesses is that a few of your labels contain a hyphen and a space

 

Like, for example, Alcatel - Lucent, something like that.

 

Cheers,

jrgo
14 - Magnetar

Hi @mekopf 

 

As @Thableaus mentioned, the REGEX you provided does seem to work. However, I'd suggest making some adjustments. Use + instead of * to ensure it matches at least 1 character. I also noticed that there's an additional space before the hyphen that your pattern was not looking for. 

 

^(.+)\s-\s(.+)\s-\s(.+)$

 

mekopf
6 - Meteoroid

I went through the later part of the label that I had to remove and found that in about 1%, the users inputting the data had manually added a hyphen and a space which was throwing off the formula. We will have to clean up the data input to make it work correctly.

 

Thanks for the help!

Labels