How to get the specific part of the string

C:\Users\xxx\yyy\zzzl\qqq\Logs\2019-11-13_Execution.log

Hello All,
In the above expression I need to get the value till third back slash ''.
means till xxx.
here string xxx can be any other string
like karan.arora or anything. but the substring as an output should be till the 3rd back slash.

Please help!

Heyy ,

I need output as C:\Users\xxx\ or C:\Users\xxx
I guess your solution is giving me xxx

Data.Split("\"c)(2).ToString
You can use split method. in above image I am using \ as a separator.

Okay got it i thought you want only xxx. I will share another screenshot

Here i am using yyy as a separator

Hi @Karan28
Use following code in Assign.
System.Text.RegularExpressions.Regex.Match(YourStringVariable,".+(?=\\yyy)").ToString .
Assign it to a string Variable.

but the value before third \ can change
like yyy can change
we need to find on the basis of third \ only

@Karan28 Then use a substring

Data.Substring(0,13).ToString

It will only work if C:\Users\xxx\ don’t change

Bro YYY will be constant here sorry , and I have applied it it is giving me this

Hi @Karan28

for the above string you can utilize the below regEx

^(C:|c:)([^\\]*\\){3}

use matches activity and then you can loop it.

Ajay

not working bro

@Karan28
Use this Str.Split(cchar("\"))(0)+"\"+Str.Split(cchar("\"))(1).Split(cchar("\"))(0)+"\"+Str.Split(cchar("\"))(2).Split(cchar("\"))(0) or
Use Str.Substring(0,13).

1 Like

what kind of data type is CurDir?
If it’s string then change it to Generic Value

1 Like

Thankyou Ajay your solution worked

1 Like

Thankyou Brother

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