Alteryx Designer Desktop Discussions

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

RegEx Tool to Parse Out Part of File Name

KmbrlyPC
8 - Asteroid

I need help with this parse in the RegEx Tool. I want to extract the department name from the filepath. Thank you!

 

Filename:Desired Result:
Food Safety Self Audit - Bakery(1-733)Bakery
Food Safety Self Audit - Grocery(1-454)Grocery
Food Safety Self Audit - Meat(1-867)Meat
Food Safety Self Audit - Produce(1-857)Produce
Food Safety Self Audit - Seafood(1-342)Seafood
7 REPLIES 7
Emil_Kos
17 - Castor
17 - Castor

Hi @KmbrlyPC,


I have prepared a workflow for you:

 

Emil_Kos_0-1612291855924.png

The output:

 

Emil_Kos_1-1612291867851.png

afv2688
16 - Nebula
16 - Nebula

Hello @KmbrlyPC ,

 

Try the following soltion:

 

Regex_Replace([Field1],'(.*\s\-\s)(.*)(\(.*\))','$2')

 

Regards 

echuong1
Alteryx Alumni (Retired)

Try this: .+\-\s(\w+)\(.+

 

echuong1_0-1612291994108.png

 

KmbrlyPC
8 - Asteroid

It worked, thank you!

KmbrlyPC
8 - Asteroid

I have a few instances in which the Department Name that I want to parse from the file path is two words. For example "Prep Foods". For these two word departments, using .+\-\s(\w+)\(.+ is not working.

echuong1
Alteryx Alumni (Retired)

Try this:

.+\-\s(\w.+)\(.+

 

This is essentially looking for text following a dash and a space, and including everything until it finds the first parenthesis.

 

echuong1_0-1612316934382.png

 

KmbrlyPC
8 - Asteroid

It works and is bringing in all the team names, thank you!

Labels