Use regular expression the easy way.
You need the php5-dev components in order to compile this PHP module.
sudo apt-get install php5-dev
$ phpize
$ ./configure
$ make
php -d extension=path/to/so/module/regexpattern.so -m
php -d extension=path/to/so/module/regexpattern.so -r 'echo REGEXP_ZIP_US_SHORT;'
$ make install # it (may require root)