Alteryx Designer Desktop Discussions

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

Regex starts with and replace words within a string

spettifor
6 - Meteoroid

Hi,

I'm parsing a long list of degree programme names which don't have consistency in the key words: Man, Manag, Manage, Management, etc. I need to convert all of these words in each string to the full "Management". The same applies to other words but I'm assuming that I need to run separate passes on these other words to repeat the process.

Trouble is that the words to change can be anywhere within the string including the end: "BSc Manag", "BSc Int Manage Full Time", "BSc Bus Man".

The regex I've worked out (and using in the RegEx node) - \b([mM]an\w) - successfully identifies the start of each word and then looks for the 'begins with' pattern. However, I'm struggling to get it to work on the end of a string as there's no subsequent characters - ie "BSc Bus Man" isn't matched as there's no char after "Man". Using \W does solve this but it then doesn't work with where there is a following character, ie "Manag"! I also can't reduce the 'begins with' pattern to [mM]a as this would also pick up 'Marketing' which I don't want...

regex.PNG

Any ideas! I'm sure I'm missing something obvious!

Also - which is better for the 'find and replace' operation -  REGEX functions in the 'Formula' node (possibly in an IF THEN ELSE statement) or stick with the 'Regex' node?

2 REPLIES 2
binuacs
20 - Arcturus

@spettifor One way of doing this

image.png

spettifor
6 - Meteoroid

Thanks binuacs! 

 

After sleeping on it I've realised that I'd just missed the greedy quantifier (*) at the end: \b([mM]an\w*) now picks up all variants including 'Man'! This regex string should be easily adaptable and should work as a reasonable 'starts with' expression.

Labels