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

Why does the Regex tool replace the matched text not the group?

IraWatt
17 - Castor
17 - Castor

For parse, tokenise, ect. the regex tool passes through the group matched.  

IraWatt_0-1653656115805.png

However with replace it replaces everything that matches and seems to ignore groups.

IraWatt_1-1653656212883.png

Why is this, is there a way around this? I believe the formula tool replace does replace based on groups. Any insight is greatly appreciated!

Thanks,

Ira

 

6 REPLIES 6
DataNath
17 - Castor

As you've left your 'Replacement Text' blank, it'll just replace the whole pattern with nothing, regardless of groups. If you want to reference capture groups and have them included in the output then you can do so as usual with '$1' etc.

 

DataNath_1-1653656952868.png

 

 

IraWatt
17 - Castor
17 - Castor

Thanks @DataNath is it possible to just replace the captured group with nothing in your example?

DataNath
17 - Castor

I think you'd just want to change the expression in that case @IraWatt - I think the only reason you'd need to include capture groups when replacing is if you want to reference any of them in the actual replacement text. If you just want to get rid of it then I'd just have the one pattern as the expression.

IraWatt
17 - Castor
17 - Castor

That makes sense thanks @DataNath 👍

binuacs
20 - Arcturus

@IraWatt something like below?

 

binuacs_0-1653663844597.png

 

IraWatt
17 - Castor
17 - Castor

Ah thanks @binuacs not how I would have considered doing it, I'm not used to the $ syntax so this helps! 

Labels