Split String which is having multiple occurrences

Hi All,

Would someone please help to understand how to split the below string which is having multiple occurrences for example (retail)? I would like to split or separate the below string as String1 and String2

Original String:

$5 copay per
prescription (retail) and
$12.50 copay per
prescription (home
delivery)
$15 copay per
prescription (retail) and
$37.50 copay per
prescription (home
delivery)

Output:

String1:
$5 copay per
prescription (retail) and
$12.50 copay per
prescription (home
delivery)

String2:
$15 copay per
prescription (retail) and
$37.50 copay per
prescription (home
delivery)

Would someone please help us to solve this .
Thanks a lot in advance for your help.

Regards
Vishnu

Hi @Vardhan

Welcome to UiPath community

You can try with Regular expression

System.Text.RegularExpressions.Regex.Matches(YourString,"(?s)(.*?)home\ndelivery\)")

image

System.Text.RegularExpressions.Regex.Matches(YourString,"(?s)(.*?)home\ndelivery\)")(1)

image

Regards
Gokul

2 Likes

Hi,
Let us know if the every string ends with (home delivery). if it ends with that we can split with (home delivery).
image

The output will be in the Array of strings and can be concated with (home delivery).

You can go with regex also for this.

cheers

1 Like

Hi @Vardhan

Checkout this

System.Text.RegularExpressions.Regex.matches(samp,"(?s)(.*?)\(home\ndelivery\)")(0)


Regards
Sudharsan

1 Like

Thank you Gokul for a clear explanation

1 Like

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