Alteryx Designer Desktop Discussions

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

Split column using RegEx (string and special characters)

Sam7
8 - Asteroid

I have 1 column of data that I require the Regex tool to split into chunks of 3 lettered string and split the special character that are in between.

 

What would the code be for known lengths of data and special characters?

Thanks

1 column data set         
ANT/CAT*DOGANT/CAT*DOG    
CAT/DOGCAT/DOG      
ANT\CAT/DOG*BAT/RATANT\CAT/DOG*BAT/RAT
4 REPLIES 4
NickSm
Alteryx
Alteryx

Hey @Sam7 

 

Can approach it a couple ways, but my take was to use a (\W) expression to find special characters, and use a Regex replace to add spaces to either side of it. Text to columns can then split this out based on the spaces.

 

You could do text-to-rows and pivot to make it more flexible on the number of columns as well.

 

Regex_SplitColumns.JPG

PhilipMannering
16 - Nebula
16 - Nebula

I would tokenize in the Regex Tool and use the expression,

\W|\w+

 

workflowworkflow 

 

benakesh
12 - Quasar

Hi  @Sam7  ,

The regex is same as   @PhilipMannering's  solution   .  Added logic to make  it dynamic  i.e  this works for  different  num of cols .

Sam7
8 - Asteroid

Thanks @PhilipMannering and @benakesh 

This is great.  It worked. 

Labels