How to Split a string value into 2 strings there is no special symbol to separate strings

i have a data below how to split a string value" 01 Use the spare part solution"
eg: first part :01
second part: Use the spare part solution

Note: starting value is changing some times 01 or 089 or etc it may any no.
and even after the no also text is changing.

Addvalue variable = “01 Use the spare part solution”.

Hi @anilkumar.vegi

Below is the solution for the same :-

String str1 = str.Split(" "c)(0)

String str2 = str.Substring(str.IndexOf(str.Split(" “c)(0))+str.Split(” "c)(0).Length)

Output :-

Mark as solution and like it if this helps you :slight_smile:

Happy Automation :raised_hands:

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

@anilkumar.vegi
Maybe itz can be setup to get triggered by the space after a digit. For this Regex.Split can help:

grafik
Line 3,6: demonstrating the split
Line 4,5: demonstrating the access to first part second part

Let us know your feedback

1 Like

Hello

Both @Pratik_Wavhal and @ppr provide some robust solutions :slight_smile:

But if the words are constant and are unlikely to change you might like to consider using a Regex Replace activity.
Use the following in an Assign Activity:
yourString = System.Text.RegularExpressions.Regex.Replace(INSERTVARIABLE, “(?=\sUse the spare part solution)”, “:”)
Regex101.com solution preview

image

image

Hopefully you will find a suitable solution :blush:

1 Like

it is coming now… after this i want to save these 2 strings into excel sheet…

Hi @anilkumar.vegi

Now it depends on the data where you have to write it.

If some data is already present and then you have to write then you can use write cell Activity or else Build Datatable Activity, Add Data Row Activity and then Append Range Activity.

If you have to write the data newly to the sheet then you can also use Build Datatable Activity & Add Data Row Activity and then Write Range Activity.

Happy Automation :raised_hands:

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

working … thanks

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