Skip to content

Mostly regex-based tool to normalize URLs, U.S phone numbers and U.S addresses

License

Notifications You must be signed in to change notification settings

ericxtang/normalic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Normalic

Easy parser/normalizer for U.S. addresses, U.S. phone numbers, and URIs.

More info

Don’t you wanna punch yourself in the face every time you have to parse and normalize this stuff?

I did repeatedly while writing this gem so you don’t have to anymore.

It tries to correct mal-formed input to the best of its ability.

Example

>> address = Normalic::Address.parse("201 Varick St. floor 12th, New York, NY 10014")
>> address.number
=> "201"

>> address.street
=> "Varick"

>> address.to_s
=> "201 Varick St., New York, NY 10014"

>> phone = Normalic::PhoneNumber.parse("00 + 1* (212) 989-9741 ext. 123")
>> phone.npa
=> "212"

>> phone.to_s
=> "212 989 9741"

>> uri = Normalic::URI.parse("github.com/ericxtang/expresso/../normalic/")
>> uri.domain
=> "github"

>> uri.scheme
=> "http"

>> uri.to_s
=> "http://www.github.com/ericxtang/normalic"

>> addr = Normalic::Address.normalize_fields("address" => "201 Varick St.",
                                          :city => "New York",
                                          :state => "NY",
                                          :zipcode => 10014)
>> addr.number
=> "201"

Note on URI parsing behavior

In the name of normalization, the URI class uses http and www as the default scheme and subdomain if they are missing from the input string.

Contributors

Eric Tang www.erictang.org

Mike Craig twitter.com/mkscrg

Aidan Feldman www.aidanfeldman.com/

About

Mostly regex-based tool to normalize URLs, U.S phone numbers and U.S addresses

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages