MODULES-1248 Fix issue with not properly counting regex matches with leg...

...acy versions of ruby