Dim String to use wildcard for dates

Jones
New Contributor III

Hey all,

Pretty new to programming but have manage to get a file moving rule to work that basically moves a file from FileShareBatchHarvest to Application /Public structure for users to pickup. 

However, the rule currently needs the exact name of file. I have tried using wildcard symbols like "* #" for the date with no success. 

Does anyone have a recommended solution to get the variable dynamic on the date section?

Jones_0-1707413448793.png

 

1 ACCEPTED SOLUTION

RobbSalzmann
Valued Contributor

Here's an example of replacing the date in your filename with today's date:

Dim fileToMove As String = "onestream_ifrs16_2023-06-15.txt"
fileToMove = Regex.Replace(fileToMove, "\d{4}-\d{2}-\d{2}", DateTime.Now.ToString("yyyy-MM-dd"))

 

View solution in original post

4 REPLIES 4

RobbSalzmann
Valued Contributor

Here's an example of replacing the date in your filename with today's date:

Dim fileToMove As String = "onestream_ifrs16_2023-06-15.txt"
fileToMove = Regex.Replace(fileToMove, "\d{4}-\d{2}-\d{2}", DateTime.Now.ToString("yyyy-MM-dd"))

 

Jones
New Contributor III

Thanks. Could you elaborate how to declare RegEx in an extender businessrule? Above gives below error message

Jones_0-1707463663154.png

 

Thanks in advance

Jones
New Contributor III

I manage to figure out, and all works based on current date. Awesome big thanks for that!

Jones_0-1707464278664.png

 

RobbSalzmann
Valued Contributor

Apologies! I left this important detail out.  And you figured it out, nice work!
Thanks for the update.

Please sign in! Jones