简体   繁体   中英

Remove Data from Address Line

I have the following address that I pulled from a database. I am trying to clear everything up until ST|AVE|BLVD. I am trying to get rid of 1ST or the random 1.

  1. 9999-1000 N CLARK ST 1 1
  2. 4567-5678 W BELMONT AVE
  3. 1200 N HAMLIN AVE 1ST 1
  4. 8220 W CERMAK RD 1ST
  5. 1240 W 69TH ST 1ST
  6. 7901 W ADDISON ST 1ST

So that it reads: 1. 9999-1000 N CLARK ST 2. 4567-5678 W BELMONT AVE 3. 1200 N HAMLIN AVE 4. 8220 W CERMAK RD 5. 1240 W 69TH ST 6. 7901 W ADDISON ST

You can try the following regex:

^(.*?)(\s*(?:ST|AVE|BLVD).*)$

Your data is in capturing group 1.

See example here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM