Substring from a Foldername

Hi everyone,

I have several folders with the following structure (the last part of the folder is also the e-mail address: C:\XYZ\2020\January\newsletter@uipath.com

I loop trough the folders, and if certain conditions apply in documents in this folder then I need to send an e-mail. Therefore I need to extract the last part of the folder (beginning from the last backslash "" until the rest of the right of the String) to use this part as the email-address.

How would the substring or RegEx look like? I need the following result in this example: newsletter@uipath.com

Unfortunately I am not that familiar with the syntax.

Many thanks
Robert

1 Like

Hi
welcome to uipath community
if the above string is in a variable of type string named str_input
then use a assign activity to get the output
str_output = Split(str_input,“\”).Last().ToString.Trim

where str_output is a variable of type string

Cheers @Robert_Heggio

3 Likes

Hi Palaniyappan,

you made my day, it works! Thank you so much!!

Best regards,
Robert

1 Like

have a great day… :slight_smile:
@Robert_Heggio

1 Like

Hi,
If I need the second last subfolder in the path what do I use instead of .Last

@Sean_Ryan1 , you can use position array number in it ()
str_input=“C:\XYZ\2020\January\newsletter@uipath.com”

str_output = Split(str_input,"")(1).ToString.Trim output = XYZ
str_output = Split(str_input,"")(2).ToString.Trim output =2020
str_output = Split(str_input,"")(3).ToString.Trim output =January
str_output = Split(str_input,"")(4).ToString.Trim output = newsletter@uipath.com