Refactor with regex library. closes issue #17