Extract values from String

I have this string C:\Users\kalpit.mantri\Documents\UiPath\ExcelCopyPaste\BRTYLP_Dec19.xlsx
I want to extract BRTYLP in str1 variable and Dec19 in str2 variable.
Is this possible?

Use
Assign
str1=Path.GetFilenamewithoutextension(“C:\Users\kalpit.mantri\Documents\UiPath\ExcelCopyPaste\BRTYLP_Dec19.xlsx”).split("“c)(0)
str2=Name=Path.GetFilenamewithoutextension(“C:\Users\kalpit.mantri\Documents\UiPath\ExcelCopyPaste\BRTYLP_Dec19.xlsx”).split(”
"c)(1)

Use Split “C:\Users\kalpit.mantri\Documents\UiPath\ExcelCopyPaste\BRTYLP_Dec19.xlsx”
split by “” then if you get the last index ,Split it again “BRTYLP_Dec19.xlsx” by “_”
so you will get the 0 and 1 index then do your desire thing in this output. @kalpitmantri

Also you can check this out for your reference.

cheers :smiley:

Happy learning :smiley:

1 Like

Hi @kalpitmantri

Please try this

string Path = "C:\Users\kalpit.mantri\Documents\UiPath\ExcelCopyPaste\BRTYLP_Dec19.xlsx" 
string str1 = Path.Split("_"c)(0).Split("\"c)(Path.Split("_"c)(0).Split("\"c).Count-1)
string str2 = Path.Split("_"c)(1).Split("."c)(0)

hope this will help

2 Likes

Hello @anoopap Thank its working.

2 Likes

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