Split_String

PO Box 898
Amherst, NY 142260898

I have a string like this…

how i need to split PO Box as one string
City - Amherst as one string
State - NY as one string
Zip - 142260898 as one string

@hairsh

Store your input in a string variable and say ‘Str’.

Try below expressions:

Str.split(Environment.NewLine.ToCharArray)(0) - PO Box 898

Str.split(Environment.NewLine.ToCharArray)(1).split(" “c)(0).replace(”,“,”") - Amherst

Str.split(Environment.NewLine.ToCharArray)(1).split(" "c)(1) - NY

Str.split(Environment.NewLine.ToCharArray)(1).split(" "c)(2) - 142260898

1 Like

Hi @hairsh

For the first time you have to split the whole text with Environment.newline delimiter Split(InputValue, Environment.NewLine). this will give you an array of strings. arr[0] is PO Box.

on arr[1] which is Amherst, NY 142260898 you have to split the text by using Space(" ") as delimiter Split(InputValue, " "). This will give you another array which will have three values. Based on index value you can assign it to respective values.

Regards,
Vijay.

Hi @hairsh

Please refer the following program
Sequence.xaml (7.4 KB)

Thanks.

Hi vijay,

But the PO Box number is not displaying here when we split this string

@hairsh

Have you tried my solution or not ?

Hi @hairsh

what is the value that you are getting after split. is it giving whole input text again ??

Yes i tried

I executed this expression by taking string = Str.split(Environment.NewLine.ToCharArray)(0)

output : PO Box 898 Amherst, NY 142260898

STR one should be PO box 898

But output is PO box

Hey @hairsh,
You can Split the string using space . Use assign activity.

str1 = address.Trim.Split(",“c)(0) ---- (for PO)
str2 = address.Trim.Split(”,“c)(1) ---- (for Box)
str2 = address.Trim.Split(”,“c)(1) ---- (for 898)
city = address.Trim.Split(”,“c)(3)
state = address.Trim.Split(”,“c)(4)
zip = address.Trim.Split(”,"c)(5)

Regard’s,
Suruchi K

Hi @hairsh

The above program is a ready-made program for your problem, run that

This solution i got by running your program.

Output : PO box
Amherst
NY
142260898

Actual output should be : PO Box 898
Amherst
NY
142260898

@hairsh

Sequence (2).xaml (7.4 KB)

Run the above

Hi @hairsh

i designed flow and it is giving expected result. Please check it and let me know it is working or not.
Sequence.xaml (8.8 KB)

Regards,
Vijay.

Solved…thanks

solved…thanks

mark the answer as solved please…

Hey @hairsh

Glad it helped you. Can you please mark this thread as solved by clicking on post which solved your problem.

Regards,
Vijay.

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