Fix regex to properly ignore comments

The /x flag in regular expressions changes the semantics of `#` to indicate comments within the regular expression -- so comments weren't actually being ignored - as demonstrated by the additions to the tests.

I noticed you're using the /x modifier in most other pattern matches in the module, and should probably also be looked at.