Coder Social home page Coder Social logo

normalic's Introduction

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/

normalic's People

Contributors

mkscrg avatar ericxtang avatar astevens avatar afeld avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.