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

Find first occurrence of a letter in a string from end

saramm
6 - Meteoroid

Hi,

 

I'm trying to find the first instance of letter X in a string and separate everything after the X into another column.

So for example the string is VM09XD12 I want to create a new column that has D12 in it. I'm not sure how to do this. Any help will be appreciated.

 

Thank you

 

7 REPLIES 7
JosephSerpis
17 - Castor
17 - Castor

Hi @saramm I mocked up a workflow let me know what you think?

 

Regex_Parse_05062020.JPG

MichaelLaRose
10 - Fireball

Hi @saramm 

 

You can accomplish this using the text to columns tool.

 

Note that I set both upper and lowercase "x" to the delimiter to make sure you always get the first x in the split.

 

Best,

Michael

Aidan_K
11 - Bolide

Hi @saramm , There is a couple of ways to do this. You can use regex tool or even the text to columns tool (to more or less achieve the sameresult). See attached example for using the text to columns tool.

regards,

Aidan

 

 

Edit:- I think there is a few of us on the same wavelength here and @saramm now has examples for all aformentioned methods 🙂

saramm
6 - Meteoroid

Thank you for your response.

 

My only worry with the text to column approach is that, it'll look for x or X in any position in the string but i'm looking for the first occurrence of X or x from the end of the string.

for example if the string is V01XMXD1 then I want to get D1 not MXD1.

Is there a way to do this using text to column or regex?

 

thank you

JosephSerpis
17 - Castor
17 - Castor

Hi @saramm I amended my workflow and should work as you describe.

 

Regex_Parse_05062020.JPG 

MichaelLaRose
10 - Fireball

I have also updated the workflow to include both methods with a side by side comparison of the behavior.

 

Best,

Michael

saramm
6 - Meteoroid

Thank you so much. This works perfectly 🙂

Labels