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:

And the C# port:

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.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s