Alteryx Designer Desktop Discussions

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

Alteryx Regex vs Regex101

MartWClimber
9 - Comet

Gooday,

 

I find that my Regex is a bit rusty. Because when I tried with Regex101.com I got an other result than in Alteryx.

 

I'm trying to parse the underscore away and I only needs the last 2 characters.

so in this example I only need AA_FH to be FH and the AA_OUT_FH to also be FH.

 

MartWClimber_0-1655716368366.png

 

In Alteryx I get this back

MartWClimber_1-1655716575820.png

 

Did something change in the Regex tool?

 

3 REPLIES 3
DataNath
17 - Castor

The reason this won't work in Alteryx, that Regex101 doesn't show so well, is that in your second test (AA_OUT_FH), there's actually 2 matches of the pattern you're providing (i.e. an underscore followed by letters) and so when you parse it, Alteryx will just provide the first match as the output. You can see what I mean if you switch the mode to tokenize (i.e. output all matches of the pattern) - you have 2 for the second line.

 

DataNath_0-1655717297504.png

 

To get around this, you can use a more specific expression. The following works if you just want to find the final 2 letters after the last underscore:

 

.+_([A-z]{2})

 

DataNath_1-1655717358905.png

 

MartWClimber
9 - Comet

Thank you for the explanation,

 

is there an other tool like Regex101 that shows in a better way what the Alteryx regex tool will output?

PhilipMannering
16 - Nebula
16 - Nebula

The reason for the discrepancy is because you've got Case Insensitivity ticked

 

Use,

 

 

_([A-Z]+)$

 

 

Labels