Start Free Trial

Alteryx Designer Desktop Discussions

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

Parsing a number from a String Using Reg Ex

pmcdonough
5 - Atom

Hello,

 

 

I am having trouble parsing numbers from two types of strings

 

EXAMPLE 1: Column1 = LC315.24

I am trying to parse this into two columns, where Column2= C and Column3 = 315.24

I used a RegEx Tool that Parses Column 1 using Regular Expression:  ( C | P)([0-9.\/]+)

I chose output method "Parse". For the output, Column2 is associated with (C | P) and Column 3 is associated with [0-9.\/]+)

The goal is for Column1 = LC315.24, Column2 = C, Column3 = 315.24.

Currently, the browse tool says the output is column1 = LC315.24, Column2 = NULL, Column3 = NULL.

Any idea how I can parse out a C or P into Column 2, and all of the numbers into Column3?

 

 

Example 2: Column1 = "PUT - XYZA 431 @ 24 EXP 05/12/2020"

I am trying to parse the number after the @ sign here (in this case 24)

My instinct is to parse the word into "24 EXP 05/12/2020" by taking everything after the @ sign (I dont know how to do that)

Then from there, I would parse out the left side of that text until a space so that I am left with "24"

Any idea how I can do that?

 

Any help is appreciated!

5 REPLIES 5
DataNath
17 - Castor
17 - Castor

Example 1 - Should be able to use the following:

 

(.+)([a-zA-Z]{1})(.+)

 

Example 2 - Should be able to use the following:

 

@\s(\d+)\s


If there’s more possibilities/combinations that turn out to render this useless then let us know and we can re-visit a solution!

DataNath
17 - Castor
17 - Castor

Apologies, can’t edit my reply as I’m on mobile but just drop the () around the .+ in the first scenario!

binu_acs
21 - Polaris

@pmcdonough one way of doing this

binuacs_0-1652476771060.png

 

 

binuacs_1-1652476801106.png

 

binu_acs
21 - Polaris

@pmcdonough your formula for the first scenario also works 

(P|C)([0-9]+\.[0-9]+)

OR

(P|C)(\d+\.\d+)
binu_acs
21 - Polaris

@pmcdonough If you want to only extract the number 24 from the second scenario you can write some thing like below

 

 

REGEX_Replace([Column1], '(.*)@\s(\d+)\s(.*)', '$2')

binuacs_0-1652477669214.png

 

 

Labels
Top Solution Authors