1👍
✅
Modify your pattern to avoid the negative lookbehind. Since you seem to want a non whitespace character as the last character, just use a character class for that.
/^(?!\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.
Source:stackexchange.com