How to split address to get city

Hello friends

I wanted to split address, so that enter in data table as per city, zip code, state…etc

Exmaple 1:
PO BOX 961260
SAN ANTONIO, TX 78269

Example 2:
PO BOX 4465
SPRINGFIELD, OH 45501

I am able to split others, only facing an issue in city column its taking hole address…i wanted only city like SAN ANTONIO, SPRINGFIELD…etc.

To get city you can try the below expression

(Split((split(Address,Environment.newline))(1),“,”))(0)

1 Like

Here is code for extracting city, state and code:

Regex.Match(Address,"(.*?), ([A-Z]{2}) (\d+)").Groups(1).ToString
Regex.Match(Address,"(.*?), ([A-Z]{2}) (\d+)").Groups(2).ToString
Regex.Match(Address,"(.*?), ([A-Z]{2}) (\d+)").Groups(3).ToString

Capture

1 Like

Hi @Bot_Learner

Checkout this expression

System.Text.RegularExpressions.Regex.Match(Stringvariable,”.*(?=,\D)”).ToString.Trim

Regards
Sudharsan

2 Likes

Hi @keerthi3595

You can try with split expression

Split(Split(yourstring,Environment.newline)(1),“,”)(0)

Regards
Gokul

1 Like

@keerthi3595 thanks for your response.

@Konrad_Mierzwa thanks for your response.

@Sudharsan_Ka thanks for the solution it works for me.

@Gokul001 thanks for your response.

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