Fixed issue #9

The regex was mostly rewritten.