Add in-memory caching of compiled regex strings
More trailing whitespace removal.
Fix rspec deprecation warnings.