Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

Parse any digits after the last underscore

jenniferte
6 - Meteoroid

Hi,

 

Need some help to parse any digits after the last underscore from the input. thanks in advance.

 

InputOutput
PLATE_Nova H2_18PLATE_Nova H2
PLATE_Monkey Bay DB2_1PLATE_Monkey Bay DB2
PLATE_MIN_Naaran_Camden_A5_11PLATE_MIN_Naaran_Camden_A5
PLATE_MIN_Daisy chani DF3_Rely A_5PLATE_MIN_Daisy chani DF3_Rely A
6 REPLIES 6
Qiu
21 - Polaris
21 - Polaris

@jenniferte 
You can do it with a Text to Column tool and set the delimiter to underscore. 😁

gawa
16 - Nebula
16 - Nebula

hi @jenniferte Regex would help. For example, you can use Regex_Replace function in Formula tool.

 

REGEX_Replace([Input], "^(.+)_\d+$", "$1")

 image.png

jenniferte
6 - Meteoroid

The solution works well. Thank you!

gawa
16 - Nebula
16 - Nebula

As @Qiu said, Text to Column tool is a good option to parse data with a particular delimiters.

Please note that Text to Column searches delimiters from left to right, so in this case, you would get the data like below, because the first _ comes after the word "PLATE":

image.png

 

If you are not familiar with Regex and prefer Text to Column tool, use ReverseString function before parse it, and revert to original order by one more ReverseString function.

image.png

Qiu
21 - Polaris
21 - Polaris

@gawa 
Thanks for the comment. You are correct.

flying008
15 - Aurora

Hi, @jenniferte 

 

Another way by formula:

Left([Input], Length([Input]) - FindString(ReverseString([Input]), '_') - 1)
Labels