Split string to get text which varies

Hello I want to extract some text to save in a variable from a file path but the text which I would want to extract changes. Can I do this from number of \s or better would be to go from right as it is text always between the final \ and 【

Below is the string
\My Documents\RPA\UiPath\SalesStuff\Project1\20190621【ReadOnly】2019_ExcelFile.xlsm

I would want to get the changing string 20190621
Thanks

@mzucker

Try this:

str = “\My Documents\RPA\UiPath\SalesStuff\Project1\20190621【ReadOnly】2019_ExcelFile.xlsm”

str.Substring(str.LastIndexOf(“")+1).Split(”【".ToCharArray)(0)

1 Like

Comes up blank, could you explain what the line means?

@mzucker

Sorry it’s my bad.

Check this:

   str.Substring(str.LastIndexOf("\")+1).Split("【".ToCharArray)(0)

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