Alteryx Designer Desktop Discussions

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

REGex Replace

SYang1
6 - Meteoroid

I'm trying to extract the following 

 

SourceResult
RIS T/F FROM 42956200004295620000
RES TF FROM 8233040415-PC8233040415-PC
228880217-01 residual t/f228880217-01
4214690617 REFUND RESIDUAL MOV4214690617
Resid Trf- 16-01355416-013554
4273700000-ST.Thomas GGG4273700000
4273700000-PC-ST.Thomas GGG4273700000-PC
4 REPLIES 4
Thableaus
17 - Castor
17 - Castor

Hi @SYang1 

 

Why doesn't "4273700000-ST.Thomas GGG " result on 4273700000-ST?

 

Could you give more details about the logic?

 

Cheers,

 

JeffF
Alteryx
Alteryx

Hi @SYang1 

 

This formula looks like it works:

 

(\d+(?:-\d+)*(?:-PC)?)

 

Regex.png

Thableaus
17 - Castor
17 - Castor

This also works

REGEX_Replace([Source], ".*?(\d+)(-(?:\d+|PC))?.*", "$1$2")

 

example1.PNG

 

Cheers,

BretCarr
10 - Fireball

This thread has gotten very very stale. Looks like I came up with nearly up the same @JeffF:

 

(?<REF>\d+(?:\-PC|\-\d+)?)

 

As a way to parse out what I am calling "REF". Other than that, @JeffS and I have close to the same answer. I am allowing for an OR with the pipe (" | ") under the guise that you would not have -##s AND -PC in your desired outcome. If you want to be able to have both, his allows that and mine is a bit stricter. Without a full set of data to look for other situations.

 

Advantage of mine would be a slight increase in speed if the data was big enough for that to make a difference.

 

Maybe someone could put this discussion to bed by marking a solution?!? 

 

Cheers!

Labels