Splitting string error

C:\Users\naveenkumar.s.clo\3D Objects\NACH\JSFB_2021-07-05-ACHDR Present2-S002 - Settlement Detail Report.xls
C:\Users\naveenkumar.s.clo\3D Objects\NACH\JSFB_2021-07-05-ACHDR Present2_R-S002 - Settlement Detail Report.xls
From i want only ACHDR Present2,ACHDR Present2_R can anyone please help me on this??

in some name contains “_R” like in this “JSFB_2021-07-05-ACHDR Present2_R”.
in Some name it wont contains “_R” like in this “ACHDR Present2-S002”.

You need the Like this?
“JSFB_2021-07-05-ACHDR Present2_R”.
or
“ACHDR Present2_R” This is enough

@Sudharsan_AIT “ACHDR Present2_R”

Have you tried with regex?

1 Like

No i didn’t try using regex I am trying using substring and split functions.

@HeartCatcher can you try below regex pattern ?

[\d]{4}-[\d]{2}-[\d]{2}-(.*)-

It seems to be working regex101: build, test, and debug regex

1 Like

@AkshaySandhu


I am new to uipath can you please guide whether it is correct which is in photo.??

If you need you can try this here is the regex

And
Here is the workflow with split
Sample.xaml (5.6 KB)

Regards,
Sudharsan

1 Like

Hi,

Another solution:

arrStr = yourString.Split("-"c)

then

arrStr(arrStr.Length-3).Trim

Regards,

1 Like

시퀀스4.xaml (6.8 KB)

1 Like

@Sudharsan_AIT


Actually file name look as in the photo it is not static, some time the file will going change.
I just need the data in between “JSFB_2021-07-05-” and “-S002 - Settlement Detail Report” these two are same in every file.

try this in log message
System.Text.RegularExpressions.Regex.Match(str_input,"[\d]{4}-[\d]{2}-[\d]{2}-(.*)-").Groups(1)

1 Like

Then You can use this inside the for each

Directory.getFiles(“C:\Users\naveenkumar.s.clo\3D Objects\NACH”)

And here is the sample workflow
Sample.xaml (6.1 KB)

@Sudharsan_AIT , thanks very much for your response, it is working fine now. may I know Split(Demo,"-")(3): what does it do
I know that split is a function, Demo is variable and splitting based on “_” but what does (3) is stands for. please dont mind i am asking too much

If we use like this it will be in array type
So for that i have given the array index there

Regards,
Sudharsan

Ok thanks.

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