Split a string up to space

Hi i am new to UI Path i have one issue please any one help me.

In Input i am getting address in single line (Address changes every time Dynamically), but in application i have to split address in 2 parts & enter address in 2 lines Address line1 & Address Line2.

Address line1 accepts 30 characters

As of now i am doing like this:

Address_Line1= Address.Trim.Substring(0,30)
Address_Line2=Address.Trim.Substring(30,Address_Length-30)

Here problem is while i am using sub-string(0,30) its splitting address up to 30 characters but its suppurates middle of the word. but i want break address up to space.

Ex :

Expected :

Full Address = 900 Mamaroneck Avenue White Plains NY

Address Line 1= 900 Mamaroneck Avenue White

Address Line 2 = Plains NY

Actual:

Full Address = 900 Mamaroneck Avenue White Plains NY

Address Line 1= 900 Mamaroneck Avenue White Pl

Address Line 2 = ains NY

Hi @NPGOPIKRISHNA

Use split instead of substring

String str=str.split(" ".ToCharArray)

Thanks
Ashwin.S

Thanks for your information,

I already split address with Space, full address is divided in to 6 words, here i have confusion up to which word i have to take for address line 1.

900 Mamaroneck Avenue White Plains NY

Have you done split based on strings

@NPGOPIKRISHNA i think you should give like this right to get your output
variable.substring(0,27)

1 Like

yes i done

But every time Address length will change address is dynamic

@NPGOPIKRISHNA so at that time you have to use split function i think,and if possible share two of your address.

Hi @NPGOPIKRISHNA

Do take length of each address and based on that you can take substring and split the value again

Thanks
Ashwin.S

@NPGOPIKRISHNA,

Based in the example given I have developed the attached script. Please check whether it works for you.Main.xaml (9.5 KB)

Address 1: Downstate Medical Center 450 Clarkson Avenue.

Expected:
Add line 1: Downstate Medical Center 450
Add line 2: Clarkson Avenue.

Address 2: Albert Einstein College of Medicine of Yeshiva University, NY.

Expected:

Add Line 1:Albert Einstein College of
Add Line 2:Medicine of Yeshiva University, NY.

@NPGOPIKRISHNA as i see there are no identical elements to separate, i think there is no possibility to make it dynamic,lets see if any body would solve it.

I have ran the above attached bot for the two example it is working fine

Thanks for your help, its working but some times when the address starts with Numerics then numerics is not considering.

Ex: 900 Mamaroneck Avenue White Plains NY

Expected:

Address Line 1 : 900 Mamaroneck Avenue White
Address Line 2: Plains NY

But when we run your code output is getting like this

Address Line 1 : 900 Mamaroneck Avenue White Plains
Address Line 2: NY

Sry, in your code i think spaces are not counting as character, but in my application Space also counting as 1 character

@MuralidharVankamaddi
Sry, in your code i think spaces are not counting as character, but in my application Space also counting as 1 character

OKay.Got it.
Please try below codeAddress.xaml (10.0 KB)

@MuralidharVankamaddi

Thanks a lot, its working fine.

What am i missing?

image

These are the dependency packages for the above xaml file.

please check the project versions.

1 Like