Merge with regexpEscape() from lib/repl.js? You probably want to move it to lib/util.js.