Get string form path

hi all,

i have a path, looks like “C:\Users\Paths\Documents\UiPath\Files\lists” stores in string data type

now i have to get output like “C:\Users\Paths\Documents\UiPath\Files” i.e.,
path up to last “”

can any one help me on this, thanks in advance

Hi @sai_krishna_somisetty

Here is the regex for the same.
image


regexr.com/57rna

Mark this as solution and like it if this helps to solve your issue :innocent:

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

thanks pratik

but how to store last string i.e., “lists” (remaining value) in other variable
String a = C:\Users\Paths\Documents\UiPath\Files
String b = lists

Hi @sai_krishna_somisetty

If you want to store both of the value in seperate variable then you must use 2 regex for that.
For appling regex for any string you have to use Matches Activity.

Here below is the SS for the another one.
image


regexr.com/57rnm

Mark this as solution and like it if this helps to solve your issue :innocent:

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

Hi @sai_krishna_somisetty

Another solution is that using Stringvariable.SubString()

Mark this as solution and like it if this helps to solve your issue :innocent:

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

Hi @sai_krishna_somisetty

I have created one workflow for you to understand both solution how it will work.

Below is the workflow.
SimpleRegex.xaml (8.0 KB)

Mark this as solution and like it if this helps to solve your issue :innocent:

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

Hi @sai_krishna_somisetty,

Please find the RegEx and how to assign it to two variables as you have mentioned.

(.*)(?=\\)\\(.*)

It will give two groups as below in the screenshot

A = RegExGroups(0).Groups(1).tostring
B = RegExGroups(0).Groups(2).tostring

RegEx.xaml (5.9 KB)

I attached the XAML for your reference

Hope it will help, Mark as Solution if you find it useful.