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

RegEx Parse Single Marked Group Multifield

BPurcell2
9 - Comet

I need to parse nearly 20 survey fields.  The problem is that 10 and 1 have descriptive text "Very Satisfied 10" and "Not At All Satisfied 1."   There are a few other fields that have slightly different text "Completely Agree 10."  Additionally, there are refused, no applicable, and null responses -- all of which should be replaced by null.

 

As a RegEx newbie, I was looking forward to using my new skill, but sadly I didn't see it in the formula options.  

 

I'm developing a different workaround, but I was curious for future knowledge, is it possible to regex parse a single marked field using multi-field?

 

Thanks.

3 REPLIES 3
Kenda
16 - Nebula
16 - Nebula

Hey @BPurcell2! I was able to use the below formula in a Multi-Field tool. The fields that did not have any numbers such as "Refused" will end up blank with this, but that can easily be modified to change them to null. Hope this helps!

 

REGEX_Replace([_CurrentField_], "(.*?)(\d*)", "$2")
MattBenj
9 - Comet

@BarnesK I see you used "$2" in the replace spot. What does this mean? How would I replace the current field with whatever was found with the pattern?

Kenda
16 - Nebula
16 - Nebula

@MattBenj Good question.

 

In short, the $2 means to return the second grouped section from the pattern portion of the RegEx call.

 

So, the generic form of the REGEX_Replace function goes like this: REGEX_Replace(String, pattern, replace)

To group sections together in the pattern section, you place parenthesis around them. In the expression in the previous post, there were two sets of parenthesis "(.*?)(\d*)". Therefore, the replace portion of the call said to return what is within the second set of parenthesis (\d*) by using the $2.

 

Hope this helps!

Labels