ALTERYX INSPIRE | Join us this May for for a multi-day virtual analytics + data science experience like no other! Register Now
The Alteryx Community will be temporarily unavailable for a time due to scheduled maintenance on Thursday, April 22nd. Please plan accordingly.

Alteryx Designer Discussions

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

Issues with keyword search using regex_match

gavin_chin
6 - Meteoroid

Hi community

 

i am trying to identify key words from a list of transaction data  and have been experimenting with the regex_match function.  However, i have come across an issue where the key word is picking up a wildcard of the key word contained in other words

 

by way of example, the regex match function uses the key word "IGA" (a local supermarket franchise) but is returning additional words that contain "IGA" such as "SPIGA" .

 

 regex_match([vendor], ".*( IGA |Woolworths|Coles|Harris Farm|Aldi|Greenwood Grocer).*")

 

For example the data set could include

 

IGA North Sydney 

IGA Lane Cove

IGA Burwood

VIA DIA SPIGA

 

How can i update this expression (or utilise other tools) to ensure i am only picking up transactions that contain an exact match to the key word? In the above example, i would only want IGA North Sydney, IGA Lane Cove and IGA Burwood to be identified and not "VIA DIA SPIGA"  

 

many thanks

 

 

Ladarthur
13 - Pulsar
13 - Pulsar

Hi @gavin_chin,

 

here is the updated RegEx, you just needed to add somethign to specify it's a word you are looking for : 

regex_match([vendor], ".*(\<IGA\> |\<Woolworths\>|\<Coles\>|\<Harris Farm\>|\<Aldi\>|\<Greenwood Grocer\>).*")

PhilipMannering
14 - Magnetar
14 - Magnetar

Or 

REGEX_Match([Field1], ".*\<(IGA|Woolworths|Coles|Harris Farm|Aldi|Greenwood Grocer)\>.*")
gavin_chin
6 - Meteoroid

Thank you @Ladarthur 

 

 Your first suggestion worked to exclude the "VIA DI SPIGA" example. 

 

However, it seems to have inadvertently excluded other genuine transactions that contained the word "IGA" - for example the results using this regex_match in a Filter tool resulted in  

 

False:  "ROMEOS FOODHALL IGA"   

 

True  "IGA COOTA" or "ROMEOS IGA OXFORD ST"  were correctly picked up.

 

In the above, i would have expected "ROMEOS FOODHALL IGA" to also be captured as 'TRUE"

 

many thanks 

gavin_chin
6 - Meteoroid

@Ladarthur

 @PhilipMannering 

this one worked perfectly 🙂

 

thank you both

Labels