I have strings like this

PO Box 898Amherst, NY 142260898…
330 West 42nd StreetNew York, NY 10036…
PO Box 3877New York, NY 10008

how i need to split PO Boxes like PO Box 898 as one string
Cities - Amherst as one string
States - NY as one string
Zip codes - 142260898 as one string

HI @hairsh,

Try using regex instead of spliting the String


1 Like

Hi @Gouda_6,

I used regex but

addresses are dynamic

Like PO Box 898 and 330 West 42nd Street…

using Regex throwing error : index out of range

Is there any method to separate dynamic addresses and city

PO Box 898Amherst


Hi @hairsh
As @Gouda_6 Regex is perfect thing in this case. Here you have example based on your Strings:


Hi @Pablito,

Regex which are provided selecting till 330 West 42nd StreetNew York.

How can the whole address to be selected like till 330 West 42nd StreetNew York.

If i am getting variable addresses in future. Does it works?


This regex101: build, test, and debug regex will throw the address till “street” as you asked. To be able to have universal Regex for your case you need to build the universal expression which will fit to your data. Sometimes it’s not easy as data may vary. That’s why I showed you this regex website as with it it’s easier to build your own expression. There is a description and nice editor which is showing everything :wink:

Anyway Address is changing dynamically, like this string
625 State St., PO Box 2207
Schenectady, NY 123012207

Regex is not working. I split the string with comma.


1 Like

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