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

Enquiry of Regex_Replace function

johnnyycchan
7 - Meteor

Hi all,

 

As some data cannot convert to some format, any syntax can solve the below situations? The main issue is to remove the most right side of symbol "-"

 

Source : 

[1] K-U-BEM-248 

[2] J-U-DCP-14730

[3] K-U-P-FSTP-GK-8500

[4] K-U-EFC2-2320

 

Output :

[1] 248

[2] 14730

[3] 8500

[4] 2320

 

Thanks a lot.

6 REPLIES 6
AngelosPachis
16 - Nebula

Hi @johnnyycchan ,

 

Would an alternative be to parse the digits and the digits with the square brackets and add them together?

 

AngelosPachis_0-1613558361961.png

 

Qiu
21 - Polaris
21 - Polaris

@johnnyycchan 

@AngelosPachis solution is enough, though want to try a differnt formula. instead of add, I do the subtract

Capture48.PNG

Tyro_abc
11 - Bolide

Hi @johnnyycchan 

You can use Two RegEx tools OR one Formula tool to get the answer. Please try the attached workflow.

arundhuti726_0-1613561013981.pngarundhuti726_1-1613561042650.png

Best Regards

Arundhuti

johnnyycchan
7 - Meteor

Hi,

 

How about the below situation? The main issue is just to keep the character(s) / number(s) after most right side of symbol "-", other character(s)/number(s)/"-" should remove. 

 

Source : 

K-U-BEM-248 

J-U-DCP-14730

K-U-P-FSTP-GK-8500

K-U-EFC2-2320

J-CS-VIP-AK-17038T

 

Output :

248

14730

8500

2320

17038T

 

Thanks a lot.

 

Best Regards,

Johnny

Tyro_abc
11 - Bolide

Here you go

 

arundhuti726_0-1613719299732.png

 

AngelosPachis
16 - Nebula

Hi Johnny ( @johnnyycchan )

 

As a side-note, another way to achieve your second request would be with a RegEx tool

 

AngelosPachis_0-1613766293340.png

 

Your captured group is whatever is in brackets, so you only want to keep everything (symbol for that is .* in Regex) that is after a dash (-). However, because you want to keep everything after the final dash of your string, you have to add .* at the front of your expression. 

 

That .* is greedy, so it will automatically take you to the final instance of a dash.

 

Hopefully that makes sense although I'm conscious it probably wasn't the best of explanations.

 

Cheers,

 

Angelos

Labels
Top Solution Authors