replace \R escape
tidy-up of regex handling
Merge pull request #21 from bramley/mantis_17035

Mantis issue 17035