The following javascript regular expression causes SyntaxError in safari: Invalid regular expression: invalid group specifier name"
/^(?!\s)[A-Za-z0-9\'\.\-\,\s]*(?<!\s)$/.test('ABCD@#');
Can someone help me rewrite the regex that will work in safari?
I found out that safari doesn't support lookbehind, but still can't rewrite the whole regex, which would be useful for safari.
P粉9491909722024-01-17 09:45:45
Modify your schema to avoid negative reviews. Since you seem to want a non-whitespace character as the last character, just use a character class.
/^(?!\s)[A-Za-z0-9'.,\s-]*[A-Za-z0-9'.,-]$/.test('ABCD@#')
Side note: Your current pattern looks wrong for what you are trying to match.