Bring your best ideas to the AI Use Case Contest! Enter to win 40 hours of expert engineering support and bring your vision to life using the powerful combination of Alteryx + AI. Learn more now, or go straight to the submission form.
Start Free Trial

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
16 - Nebula
16 - Nebula

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 Alumni (Retired)

hi @slckkrky ,

 

you can use the regex_countMatches function. hope this helps!

 

bpatel_0-1574701782874.png

Labels
Top Solution Authors