Forum Discussion

Jones's avatar
Jones
New Contributor III
11 months ago

Dim String to use wildcard for dates

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?

 

  • 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"))

     

  • RobbSalzmann's avatar
    RobbSalzmann
    Valued Contributor II

    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's avatar
      Jones
      New Contributor III

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

       

      Thanks in advance

      • Jones's avatar
        Jones
        New Contributor III

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