Fix broken regexp rule creation

.substr(1, -1) would result in an empty string, creating a regexp that would match anything.
Using .slice(1, -1) instead removes the first and last character as intended.