Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

How to parse last two digits from an alphanumeric string (product code)?

thepirate2008
5 - Atom

I was hoping some of the more experienced Alteryx users could help me out with how to go about separating the last two digits/characters from what we would call a product code from our database list. An example would be product code J2102HG05. Usually the last two digits/characters, in this case 05, has a unique meaning to us which we are looking to identify for some upcoming projects. I would like to split the original product code such as J2102HG05 to two columns, one being the main stem of the code such J2102HG and the other column being 05. I think my answer would be using the parse method from the Regex tool but I am stuck on developing the expression. 

4 REPLIES 4
RolandSchubert
16 - Nebula
16 - Nebula

What about simply using a Formula tool with functions RIGHT and LEFT?
See attached workflow.

GiuseppeC
Alteryx
Alteryx

The previous solution works! If you are really looking at using the Regex tool, here it is.

The expression extract 2 goups:

- (^beginning of fied followed by any number of characters)

- (any two characters followed by end of line$)

 

Hope this helps!

danilang
19 - Altair
19 - Altair

hi @thepirate2008 

 

Any time I see the word "Usually" in a problem statement, as in "Usually the last two digits/characters", I double my time estimate.  @RolandSchubert has a great, simple solution, but it depends on the data always having those last 2 characters.  Do you have any special cases you need to deal with?  If so, then a regex solution is better suited to handle those.

 

Dan

 

thepirate2008
5 - Atom

Thank you everyone for the help. Luckily, with this specific set of data, the last two digits were unique and the left right formulas were able to be used here with the first suggestion. I did not even think of that, I was so dead set on the Regex tool. I did use the Regex tool as well and that worked as well and helped me begin to understand how to form a Regex expression. Thank you for all your help!

 

@danilang 

 

You are so right about "usually" luckily in this case I scoured the data prior and knew that was the case for this specific set of data. Thank you so much!

Labels