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 Match and Regex Replace doesnot give same result

slckkrky
8 - Asteroid

Hello everyone

 

I keep trying to figure out but I couldnot and it sounds weird to me. Regex Replace is replacing specific phrase as I want , however regex match doesnot match same phrases. Any ideas?

 

Thank you in advanceCapture.PNG

4 REPLIES 4
OllieClarke
15 - Aurora
15 - Aurora

Hi @slckkrky the REGEX_MATCH() function has to match the entire string, so if you change yours to:

REGEX_MATCH([field1],'.*(youth|region)+.*')

then you'll get what you want. You've also got your contains function round the wrong way. The first parameter of Contains() should be the string you're searching, the second is what you're searching for.

OllieClarke_0-1574700301092.png

Hope that helps,

 

Ollie



fmvizcaino
17 - Castor
17 - Castor

Hi @slckkrky ,

 

For this method, it looks for full string matches rather than partial matches, so based on that, for that function to work, you need to insert .* at the beginning and the end to control anything else in your string.

.*(youth|region).*

 

Best,

Fernando V.

Thableaus
17 - Castor
17 - Castor

Hi @slckkrky 

 

REGEX_Match considers the full expression, REGEX_Replace considers partial portions of the string.

 

You could use something like this:

 

REGEX_Match([Field1], ".*(youth|region).*")

 

This matches anything that has either youth or region on it.


Cheers,

bpatel
Alteryx
Alteryx

hi @slckkrky ,

 

you can use the regex_countMatches function. hope this helps!

 

bpatel_0-1574701782874.png

Labels