Phone number parsing is a bitch

Having spent the last couple of weeks looking for a decent implementation of a generic phone number parser that works with international numbers I’ve continually come up short.

I finally started writing my own custom one when lo and behold I happen to stumble across an awesome C# port of the library that Google uses in its Android platform to parse phone numbers.

Not only will this library support a format like +61 03 9123 1234 but can also understand extensions like this +61 03 9123 1234 ext 1234

Here is the original Java code: http://code.google.com/p/libphonenumber/

And the C# port: https://bitbucket.org/pmezard/libphonenumber-csharp/wiki/Home

While I definitely don’t think its perfect and structurally ugly (in my opinion as a result of being a Java clone), its damn near close and building anything nearly as good would be a significant effort.

Advertisements