Let’s talk Alteryx Copilot. Join the live AMA event to connect with the Alteryx team, ask questions, and hear how others are exploring what Copilot can do. Have Copilot questions? Ask here!
Start Free Trial

Alteryx Designer Desktop Discussions

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

Split column by RegEx

Wojtek_Dz
8 - Asteroid

Hello, could you help me to write proper regex ?


Input: PL30210T,PL30370T-PL30045B+PL30260B+PL30220B+PL30379T


Output: PL30210T ,PL30370T -PL30045B +PL30260B +PL30220B +PL30379T

 

For now I use 2 RegEx tool one by another:

1. (\w+) and output method Parse output: PL30210T

2. ([+|-]\w{8})  and output method Tokenize output: -PL30045B +PL30260B +PL30220B +PL30379T

 

PL30210T ,PL30370T-PL30045B +PL30260B +PL30220B +PL30379T - and I don't know how to separate this bolded part.

 

Is it some better way to solve it ?

7 REPLIES 7
Christina_H
14 - Magnetar

I'm not entirely clear what output you're looking for, but if you use this in a single RegEx tool on Tokenise you'll get all 6 codes output with any preceding symbol.  You can then trim off the comma if necessary.

\W*\w{8}

Christina_Hurrell_0-1636460617110.png

 

Wojtek_Dz
8 - Asteroid

I want to receive an output line this.

 

Col1Col2Col3Col4Col5Col6
PL30210T,PL30370T-PL30045B+PL30260B+PL30220B+PL30379T

 

Sorry for the lack of clarification.

Sebastiaandb
12 - Quasar

@Wojtek_Dz Here you go!

 

Sebastiaandb_0-1636461361360.png

 

Greetings,

 

Seb

 

Jonathan-Sherman
15 - Aurora
15 - Aurora

Hi @Wojtek_Dz,

 

Taking the original text string:

PL30210T,PL30370T-PL30045B+PL30260B+PL30220B+PL30379T

 

I'd first go down the route of adding in a delimiter to split on, in my case i've chosen to use a pipe "|". Added these into the test string using a Regex_Replace() function:

 

REGEX_Replace([Text], "(\W)", "|$1")

 

This edited the text string to add the pipe delimiters in place:

PL30210T|,PL30370T|-PL30045B|+PL30260B|+PL30220B|+PL30379T

 

Allowing us to now split the string with a text to columns tool:

JonathanSherman_0-1636461375864.png

 

I've attached my workflow for you to download if needed!

 

Kind regards,

Jonathan

 

Wojtek_Dz
8 - Asteroid

Thanks @Sebastiaandb and @Jonathan-Sherman for quick answer. Both of those are great but the solution of @Jonathan-Sherman is more user friendly.

Sebastiaandb
12 - Quasar

@Wojtek_Dz @Jonathan-Sherman  haha it is (arghhhh ;-))!

Christina_H
14 - Magnetar

@Wojtek_Dz If you switch my RegEx version to tokenise to columns instead of rows you'll get your output from a single tool.  Just increase the number of columns to accommodate your data.

Labels
Top Solution Authors