Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

How to parse a text string

chc10
7 - Meteor

Hi,

I've got data that reads like this:

 

YY_BREAKFAST_FOODS_CAT_AB_SFF_PROD

YY_ICE_CREAM_CAT_AB_SFF_PROD

 

I want to parse the strings to output:

 

BREAKFAST_FOODS

ICE_CREAM

 

Pls can you help me?  Thanks.

 

 

 

6 REPLIES 6
JosephSerpis
17 - Castor
17 - Castor

Hi @chc10 I mocked up a workflow using regex. Let me know what you think?

chc10
7 - Meteor

Perfect thank you!

chc10
7 - Meteor

Hi Joseph, the regex you kindly sent me doesn't work in all use cases.  Attached is my additional data where it fails in some cases.  Can you help pls?Thanks Harry

Ben_H
11 - Bolide

Hi @chc10,

 

I've adjusted the Regex in Josephs example however it still won't quite work for all your examples as the structure varies in the total rows. So it would need further work in that case.

 

I also included a non-regex example that you could use instead if that helps.

 

This approach uses a match to replace values before and after the bit you want to keep, the downside vs. regex is that you have to specify the match values, where as regex doesn't care what the values are as long as they match the structure. You also have to be mindful of the order in which it replaces values with this method.

Ben_H_0-1597653381925.png

 

Regards,

 

Ben

 

grazitti_sapna
17 - Castor

Hi @chc10 , try this if it works for you?

Thanks.

grazitti_sapna_0-1597655304249.png

 

Sapna Gupta
JosephSerpis
17 - Castor
17 - Castor

Hi @chc10 I amended the workflow to work for that example of data. With regex you need to match it to the pattern in your string. For that example in the data you supplied there where three patterns. If new patterns occur then you need to amend the regex for it. If you not familiar with regex would recommend the Parsing Data lessons on the community. 

Labels