We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

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

Reverse RegEx

rheepa
7 - Meteor

Hi All,

 

I have the following string "stuff.my___1_year_on_practice". My Regular Expression looks like "((?:[^_]*){1})$". I am trying to Parse "practice" beginning at the end. The {1} means the last "_". Instead of "_" I want to do the last instance of any of: "abc_|def_|[0-9]_". So, for example, if my string is "stuff.my___1_year_2_practice_32", I want to match "practice_32". I think I almost have it but can someone help me get the last part working? Also, my expression creates two matches when I only want one.

 

Thank you so much!

 

 

 

6 REPLIES 6
apathetichell
20 - Arcturus

 

Does - ".*_(\w+_\w+)$" work?

 

apathetichell
20 - Arcturus

 also - you want "practice" in your first example but "practice_32" in your second example?

binuacs
21 - Polaris

@rheepa one way of doing this. 

REGEX_Replace([Input], '.*_([a-z]+.*)', '$1')

 

binuacs_0-1650018214765.png

 

rheepa
7 - Meteor

Hi! Yes, I'm looking for "practice" in the first example and "practice_32" in the second example. So I'm looking for a way to stick something like (?:abc_|def_|[0-9]_) into the expression, with abc and def being specific strings and [0-9] as any digit. I also want to avoid two results being matched when doing this. Thanks for looking into this!

rheepa
7 - Meteor

Hi! Just to clarify, "abc" and "def" are specific strings in my problem and the "32" in "practice_32" doesn't have to be a digit. Thanks for looking into this!

apathetichell
20 - Arcturus

abc and def have a variety of possibilities - yes?

otherwise I'd use regex in parse mode with ".*_(abc_*\d*)$|.*_(abc_def)$" and then deal with the two columns later.

Labels
Top Solution Authors