Extract Street Address without Numbered Street Names

Jason Carter

I'm trying to extract the street number from addresses such as this:

1520 32nd Street
3215 Sheldon Rd

But replacing not digits, gets the 32 out the first.

python>  re.sub(r'\D', '', street)
152032
3215

I'm pretty sure I need a negative look around, but I can't get it right.

larsks

It looks like your task would be easier if you were first to engage in the process of address normalization: converting addresses into a standard format with well-defined fields. There are various tools out there for doing this; the usaddress module seems to work well for US addresses.

>>> import usaddress
>>> addr = usaddress.tag('1520 32nd St')
>>> addr[0]['AddressNumber']
'1520'

And for your second address:

>>> addr = usaddress.tag('3215 Sheldon Rd')
>>> addr[0]['AddressNumber']
'3215'

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

To extract street number from street address using regex from a dataframe in python

Split street address into street number and street name in r

How to extract street, city, etc. from GMSPlace Address Components

ordering street address in MS SQL

Python create a street address table

Cross referencing street and city names

PL/SQL split full address in street number and street name

The ultimate tool to split/extract street name from street number

Regex to extract street from full address but leaving out optional directional component

Combine street number and route in Address autocomplete api

Prevent Outlook (Web) Style Change on Street Address

Split street, house number and addition from address

Splitting pandas address into street and house numbers

Regex: Omitting street address up until the city?

Python/Pandas - remove street number from address

EF: The property 'Street' is not a declared property on type 'Address'

ABPeoplePickerNavigationController predicateForEnablingPerson - What is the Predicate Format for Street Address?

php - validate street address with regular expression

Get Street Address From Contact Swift

iOS App Store Submission Requires a Street Address

Split full address to contain only street name

Deny Checkout if Street Address is on blacklist WooCommerce

How to parse an address string to street and house number

Capturing Street Address Through Voice for Bixby

HTML Email - Tappable street address in Android

Extracting and then combining Street Address and Apartment Numbers in pandas

PHP Geolocation (Street Address -> Lat-Long)

Get embedded street view from an address

Windows Phone 8 - Getting Multiple Street Names