REGEX works in chrome but breaks in safari
P粉506963842
P粉506963842 2024-01-16 15:38:53
0
1
659

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粉506963842
P粉506963842

reply all(1)
P粉949190972

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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template