Why is /[\w-+]/ a valid regex but /[\w-+]/u invalid?
问题 If I type /[\w-+]/ in the Chrome console, it accepts it. I get a regex object I can use to test strings as usual. But if I type /[\w-+]/u , it says VM112:1 Uncaught SyntaxError: Invalid regular expression: /[\w-+]/: Invalid character class . In Firefox, /[\w-+]/ works fine, but if I type /[\w-+]/u in the console, it just goes to the next line as if I typed an incomplete statement. If I try to force it to create the regex by running eval('/[\w-+]/u') , it tells me SyntaxError: invalid range in