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 Text

samxhander09
8 - Asteroid

Hi, Im new here and im wondering how can I parse the below without having to use 3 regex tool?

expressions for parsing 

(764\d{7})

(615\d{7})

(792\d{7})

 

SAMPLE VALUES TO PARSE
7642313537
6156701028
7926589011
7642313874
7926589000
6156549028
6151000002
7642333879

 

Thank you in advanced!

6 REPLIES 6
Clifford_Coon
11 - Bolide

Hi Sam,

 

Here's a thought:

 

If it's always the first 3 characters, you can use a string formula.

String:        tonumber(left([Value],3))

Number:    tonumber(left(tostring([Value]),3))

SPetrie
13 - Pulsar

(764\d{7}|615\d{7}|792\d{7})

The | character is an or, so its saying match this, or this, or this.

SPetrie_0-1680553739299.png

 

samxhander09
8 - Asteroid

Hi guys, appreciate the reply, I was wondering if this would parse the data into three columns? just like when I use 3 regex tool?

like for column 1 it would have all data that start with 764 and so on for column 2 those 615 and column three 792?

SPetrie
13 - Pulsar

Also possible with one tool. A light adjustment to the expression to make each option its own capture group

(764\d{7})|(615\d{7})|(792\d{7})

then a bit of setup for the columns in the regex tool

SPetrie_0-1680615307599.png

 

SPetrie_1-1680615333992.png

 

 

danilang
19 - Altair
19 - Altair

Hi @samxhander09 

 

Here's a dynamic, non-regex way to to group and crosstab your values

danilang_0-1680615835000.png

The Keys input contains the key (764,615,etc) and a field for the column number.  Use a Find Replace tool configured to match the start of the field and append the Column Number field.  Sort, add row numbers and crosstab for the result.  The Dynamic Rename replaces the column numbers with the keys to give 

danilang_1-1680616043838.png

To make this dynamic, change the Keys input to a Input Data tool and keep the list of keys and columns in a shared location.  

 

Dan

samxhander09
8 - Asteroid

Hi, thank you for the massive help! Was able to get the desired output. Have a great day!

Labels
Top Solution Authors