modifying regex string matcher to be compatible with older versions of ruby