Alteryx Designer Desktop Discussions

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

RegEx Assistance Needed

thenning
Meteoro

Hi everyone!  I'm very new to using RegEx and cannot seem to figure out how to accomplish the following with these file names from the Directory tool:

  1. Only looking to pull in the .csv files with the naming convention of CPSC_Contract_Info_YYYY_MM.csv or CPSC_Enrollment_Info_YYYY_MM.csv (don't need any that are labeled as "old", etc.)
  2. Want to change the underscore in between YYYY_MM to a hash mark (YYYY-MM)
  3. Isolate YYYY-MM in its own column

Any assistance would be greatly appreciated.  Thanks!

4 RESPOSTAS 4
Luke_C
Castor

Hi @thenning 

 

Here's some examples:

 

Filter files: 

REGEX_Match([FileName], 'CPSC_Contract_Info_\d{4}_\d{2}.csv')
OR
REGEX_Match([FileName], 'CPSC_Enrollment_Info_\d{4}_\d{2}.csv')

Replace underscore: 

REGEX_Replace([FileName], '(.*\d{4})(_)(\d{2}.*)','$1-$3')

Isolate yyyy-mm:

REGEX_Replace([FileName], '.*(\d{4}.\d{2}).*','$1')

 

 

Luke_C_0-1655490728917.png

 

thenning
Meteoro

Thanks @Luke_C, that did it.  I appreciate your help.

mark007
Asteroide

Hi @thenning - as someone who has only recently fallen down the rabbit hole of regex, I find this website a great source for regex.  https://regex-generator.olafneumann.org/. You can paste your expression in and using the UI, isolate how you want to identify it and it will produce the required regex.  It is by no means foolproof, but a good place to start and then make further tweaks to get to what you finally need.

tandon
Asteroide

This site is really great to test regex  https://regex-generator.olafneumann.org/. Thanks @mark007 

Enquetes
We’re dying to get your help in determining what the new profile picture frame should be this Halloween. Cast your vote and help us haunt the Community with the best spooky character.
Don’t ghost us—pick your favorite now!
Rótulos