Alteryx Designer

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

Regex Match and Regex Replace doesnot give same result

Highlighted
7 - Meteor

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

Highlighted
Alteryx Certified Partner

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



Highlighted
Alteryx Certified Partner
Alteryx Certified Partner

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.

Highlighted
Alteryx Certified Partner
Alteryx Certified Partner

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,

Highlighted
Alteryx
Alteryx

hi @slckkrky ,

 

you can use the regex_countMatches function. hope this helps!

 

bpatel_0-1574701782874.png

Labels