regex street address match

前端 未结 4 592

While I know that matching a street address will never be perfect I\'m looking to create a couple of regex statements that will get close most of the time.

I\'m tr

4条回答
  •  无人及你
    2020-11-29 09:43

    I needed to do something similar for addresses like

    800 SE 20 AVENUE #603, DEERFIELD BEACH

    9801 NW 3 STREET APT 5, PLANTATION

    11909 GLENMORE DRIVE #4-1, CORAL SPRINGS

    This is the regex that I used

    \s*([0-9]*)\s((NW|SW|SE|NE|S|N|E|W))?(.*)((NW|SW|SE|NE|S|N|E|W))?((#|APT|BSMT|BLDG|DEPT|FL|FRNT|HNGR|KEY|LBBY|LOT|LOWR|OFC|PH|PIER|REAR|RM|SIDE|SLIP|SPC|STOP|STE|TRLR|UNIT|UPPR|\,)[^,]*)(\,)([\s\w]*)\n
    

    It returns separate groups for each part of the address (I did not need to parse state name for my case). Try it out here https://regex101.com/r/OsvOxn/3

提交回复
热议问题