Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

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

Regex - match everything after the second to last dash

gwiz
8 - Asteroid

Hi all, I am trying to match everything after the second to last dash in a file which contains strings with hyphens or dashes. In each line is a string with a series of letters, numbers, and dashes. I would just like to extract everything after the second to last dash.

See examples below:

 

ab2372347234tfashdjfawhewe-c3

ab534572hasdfaj32rahafd32135466324-c1

dude-fhdhe12-ab5438472dsfawe35b3-c4

abtt78923dahdfajh23498kljcxcze

8ver238234923adfadhfahdabc33

gretorg-xsss47-hireball-rhetaama3-01

cn3-vov-4

YCMCDE7888132892-5

gretvrg-dae01-hetprotesh-dug-02

pret-grab01-vov-sebastian-03

 

Therefore for "gretvrg-dae01-hetprotesh-dug-02" I would just like dug-02 and then the next step would be to have "dug" in one column and "02" in another. For "cn3-vov-4" I would like "vov-4" and the next step would be to have "vov" in one column and "4" in another. For "dude-fhdhe12-ab5438472dsfawe35b3-c4" I would like "ab5438472dsfawe35b3-c4" and then the next step would be to have "ab5438472dsfawe35b3" in one column and "c4" in another. Etc etc.

 

Some have four dashes, some have three or two dashes, and some have none as you can see.

So that is why I would like to grab everything after the second to last dash. For the ones that don't have a dash its no big deal because I am planning to just bring those in at the end anyways. I am not having success working on this, as I have for the whole day so I would appreciate any help.

 

I tried doing this in a regex tool on tokenize output method, which gets everything after the last dash but thats the closest I can get: [^-]+$

Thank you so much for the help!

 

10 REPLIES 10
gwiz
8 - Asteroid

Hey @MarqueeCrew Thanks for the solution and the subsequent explanations. I really appreciate it. I would love to be at Nashville, it is very inspiring ;), but currently not sure if my company would sponsor me to go.

 

Thank you for the resources/links as well. I will be sure to check those out.

 

Regards,

Greg

Labels