Missed the Q4 Fall Release Product Update? Watch the on-demand webinar for more info on the latest in Designer 24.2, Auto Insights Magic Reports, and more!
Free Trial

Alteryx Designer Desktop Discussions

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

Regex select values under a certain amount

bman213
7 - Meteor

Hi all,

 

I have 6 numbers in an ID that I want to split up with a hyphon. The expression I have been using is:

 

LEFT([assetid],2) + "-" + RIGHT([assetid],4)

 

So if I have 123456

 

I would get 12-3456. Which is great, The only issue I am having is that if the right side of the string is less than 4 digits, it doesnt seem to include it in the output.

 

Any help to rectify this so that I could have 12-3456 or 12-345 or 12-34 would be greatly appreciated!

 

3 REPLIES 3
apathetichell
19 - Altair

RIGHT([assetid],4)

 

becomes:

 

right([assetid],length([assetid])-2)

bman213
7 - Meteor

You are a hero sir! Thank you

apathetichell
19 - Altair

Thanks! Fyi - a regex way to do the same split would be:

REGEX_Replace(tostring([Field1]),"(\d{2})(\d+)","$1-$2") (match the first 2 digits, in group 1, match the remainder digits in group 2, and then output group1 "-" group 2)

 

but If the everything is fairly static I'd stick with left/right stuff...

Labels
Top Solution Authors