Free Trial

Alteryx Designer Desktop Discussions

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

Adjust regex to account for second alpha-numeric designator separating it from values

hellyars
13 - Pulsar

Regex question.  I need to separate Field1 into 2 outputs.  The regex expression below parses Field1 correctly 99%.  The pattern is a 1-3 digit number \d{1,3}, a space \s, a designator that contains letters and numbers, a space, and then a series of 1 to 3 values that can be either positive or negative.   

 

 

 

(^\d{1,3}\s.*?)\s(.*$)

 

 

 

The problem can be seen in the first row below.  The row that starts 165... contains a second designator that contains both numbers and letters before the 1 to 3 positive or negative values.  In this example, the expression above fails to catch this second designator.  How can I fix it?

 

 

Field1WRONG 1st Group (First Row is wrong)DESIRED 1st Group
165 D–35 C2D2 785336 409524 -375812165 D-35 165 D-35 C2D2
1 D–35 -45671 D-351 D-35
20 Q–9 29409 -2940920 Q-920 Q-9
59 E–4 58803 44140 -1466359 E-459 E-4
5 REPLIES 5
hellyars
13 - Pulsar

I came up with a brute force solution using the following expression.

 

 

(^\d{1,3}\s.*?\s\w*?)(\d{2,8}.*$)|(^\d{1,3}\s.*?\s.*?)\-\d{1,8}

 

 

But, it creates additional output fields, when I only want two.  

atcodedog05
22 - Nova
22 - Nova

Hi @hellyars 

 

Here is a workflow for the task.

Output:

atcodedog05_0-1605074283874.png

Workflow:

atcodedog05_1-1605074299275.png

Formula:

TrimRight(REGEX_Replace([Field1], "\s-?\d+", "|$1"),"|")

Hope this helps 🙂


If this post helps you please mark it as solution. And give a like if you dont mind 😀👍

PhilipMannering
16 - Nebula
16 - Nebula

I think this works in the Regex Tool set to Parse,

 

(.*\u\S*) (.*)

 

P

hellyars
13 - Pulsar

@atcodedog05  Quick question.   What if I wanted to output the leftover values in a second column?

hellyars
13 - Pulsar

@PHIS Thank you.  This also works and allows me to parse the title/ designator from the dollar values.  

Labels
Top Solution Authors