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] JL225* 

[2] KM*130

[3] **WY2294

[4] UV3*35*7

 

Output :

[1] JL225

[2] KM*130

[3] WY2294

[4] UV3357

 

Thanks a lot.

 

Best Regards,

Johnny

3 REPLIES 3
TomWelgemoed
12 - Quasar

Hi @johnnyycchan ,

 

This is a bit clumsy, but represents how my mind works!

 

if Contains([Field 1], '*')
Then
ReverseString(substring(ReverseString([Field 1]),FindString(ReverseString([Field 1]),'*'),Length([Field 1])-1))
else [Field 1]
endif

 

I'm basically reversing the text, finding the first instance of the character we're looking for, doing a substring from that point forward and then reversing the string back again. And I only do that where this character exists.

 

TomWelgemoed_0-1615805547675.png

 

 

Hopefully that helps?


Regards,

Tom

johnnyycchan
7 - Meteor

HI Tom,

 

It works. Thanks a lot.

 

Best Regards,

Johnny

TomWelgemoed
12 - Quasar

Glad to hear, you're welcome.

Labels