Separate part of a path on Excel

Hi Team,

I had an assign activity to separate part of this path
“K:\QualityAssurance\Majid Al Futtaim\MAF\Omar\Transformation\Projects\BOTs\Onboarding BOT\OB Folder\Account 1\IDs”
and the part i wanted to separate was "Account 1 " and the expression was

System.Text.RegularExpressions.Regex.Match(DTPhotos, “Account\s\d+”).Value

however the plan has changed and the new path is \10.124.101.70\eg\Cairo\Public\Power BI\Onboarding WFRs\Talabat - Talabat AVENE GHC BO - 1 - 3858199\National IDs

so how can i modify the expression to take the “Talabat - Talabat AVENE GHC BO - 1 - 3858199” part please note: that this part could have numbers or not it could be anything so i need to separate the part between Onboarding WFRs and National IDs

@omar_ismail

Ifeally if you need the last second then you can use this…irrespective of ehat is there before and after

Str.Split({"\"},StringSplitOptions.None)(Str.Split({"\"},StringSplitOptions.None).Count-2)

Str is the variable where the required path is stored

Cheers

@omar_ismail

You can get that by using this expression:

Result = str_Path.Split("".ToCharArray).Reverse()(1)

Hope it helps.

image
i got this error

@omar_ismail

Str should be the variable whoch contains your string…please declare a variable as str or replace str with the actual variable you have the path in

Cheers

Hi @omar_ismail

You can use the split function to split by the \ slash, can get the output.
Follow the below one

Store the path in a String variable
- Assign -> Demo_Str = " \10.124.101.70\eg\Cairo\Public\Power BI\Onboarding WFRs\Talabat - Talabat AVENE GHC BO - 1 - 3858199\National IDs"
Take another assign and store the array of split in array variable
- Assign -> Demo_Arr = Demo_Str.Split("\")
Take another assign activity to store the output String variable
- Assign -> Output = Demo_Arr(Demo_Arr.Length-2)

Follow the below workflow for better understanding

You can use the same workflow for both paths to extract account1 nd Talabat - Talabat AVENE GHC like this.

Hope it helps!!

1 Like

Thank you @omar_ismail

If you find the solution for your query. Mark it as solution to close the loop.

YourStrPath.Split ("" c, StringSplitOptions.RemoveEmptyEntries.RemoveEmptyEntries).Reverse(). Skip(1).Take(1). First()

Try below

strPath = "\\10.124.101.70\eg\Cairo\Public\Power BI\Onboarding WFRs\Tealabat - Talabat AVENE GHC BO - 1 - 3858199\National IDs"

Log Message = Path.GetFileName(Path.GetDirectoryName(strPath))

Hi
Try this in Assign
InputPath= \10.124.101.70\eg\Cairo\Public\Power BI\Onboarding WFRs\Talabat - Talabat AVENE GHC BO - 1 - 3858199\National IDs
Output= System.Text.RegularExpression.Regex.Match(InputPath,“(?<=Onboarding WFRs).*(?=National IDs)”)

Thanks