Fixed an exception thrown from illegal characters in a regex