Split question

Hi~

I selected a file by the function “select file”
file path is “\nas123\abc\abc\abc\RPA\UiPath\abc\Corporate Actions 7 Mar 2022.xlsx”
the file output to variables “file_Input”

Then I used the function “Assign” to have “7 Mar” of the file name but error message shows “Assign: Index was outside the bounds of the array”.

How can I amend to the bleow value of function “Assign”? Thank you.
Split(Split( file_Input,“")(7),”“)(2)+”/“+Split(Split( file_Input,”")(7)," ")(3)

Hi,

I think it’s better to use filepath method and regex as the following. can you try this?

System.Text.RegularExpressions.Regex.Match(System.IO.Path.GetFileNameWithoutExtension(yourString),"\d+\s[A-Za-z]{3}(?=\s\d{4}$)")

Regards,

Hi Yoichi,

Thank you for your reply.
Sorry, I don’t really understand your solution, shall I put “System.Text.RegularExpressions.Regex.Match(System.IO.Path.GetFileNameWithoutExtension(yourString),”\d+\s[A-Za-z]{3}(?=\s\d{4}$)“)” in the right blank of function Assign?

Hi,

I forgot to add ToString or Value. Can you try as the following image?

strDate = System.Text.RegularExpressions.Regex.Match(System.IO.Path.GetFileNameWithoutExtension(yourString),"\d+\s[A-Za-z]{3}(?=\s\d{4}$)").Value

Regards,

Hi Yoichi,

Its work, thanks a lot.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.