百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
S

street-address

> 编程语言
开源

检测和分解字符串中的美国街道地址。

170 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

检测和分解字符串中的美国街道地址。

StreetAddress

Parses a US street address string and returns a normalized Address object. Returns nil when the string is not a recognized US address format.

This is a port of the Perl module Geo::StreetAddress::US originally written by Schuyler D. Erle.

Ruby Version

Requires Ruby 3.3 or later. For Ruby 2.x support, use gem version 1.0.6.

Installation

bash
gem install StreetAddress

then in your code

ruby
require 'street_address'

or in your Gemfile

ruby
gem 'StreetAddress', require: 'street_address'

Basic Usage

…

ZIP+4 Support

ruby
address = StreetAddress::US.parse("5904 Richmond Hwy Ste 340 Alexandria VA 22303-1864")
address.postal_code     # "22303"
address.postal_code_ext # "1864"
address.full_postal_code # "22303-1864"

# Also works without the hyphen
address = StreetAddress::US.parse("5904 Richmond Hwy Ste 340 Alexandria VA 223031864")
address.postal_code_ext # "1864"

Intersection Parsing

ruby
address = StreetAddress::US.parse("Hollywood Blvd and Vine St, Los Angeles, CA")
address.intersection? # true
address.street        # "Hollywood"
address.street_type   # "Blvd"
address.street2       # "Vine"
address.street_type2  # "St"

Stricter Parsing

ruby
address = StreetAddress::US.parse_address("1600 Pennsylvania Avenue")
# nil - not enough information to be a full address

address = StreetAddress::US.parse_address("1600 Pennsylvania Ave, Washington, DC, 20500")
# Returns Address object - full address provided

Known Limitations

  • US addresses only (returns nil for international addresses)
  • PO Boxes are not supported
  • Military addresses (APO/FPO) are not supported
  • Rural routes (RR) and highway contract routes (HC) are not supported
  • Addresses ending in "United States" or "USA" may not parse correctly

License

The MIT License

Copyright (c) 2007-2026 Derrek Long and Contributors

Issues· 11 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Ruby

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言