Check that its a string containing '@' with at least one character before and after the @ symbol is usually the only sensible thing to do.
This is exactly what the regex in the example is doing. Check that its a string containing '@' with at least one character before and after the @ symbol is usually the only sensible thing to do.
This is exactly what the regex in the example is doing.This would reject valid email addresses using quoted parts like john."@".doe@valid.example.
Edit: Looking at it closely it looks like the attempt is to reject anything with an '@' in the user part, which would be an error (e.g. john."@".doe@valid.example). Except since "\S+" also includes '@' this regex will still work, but by accident. It would reject the valid email john."\ ".doe@valid.example
/^[^@\s]+@\S+$/.test("john.\"@\".doe@valid.example") == true
Edit: Hmm, I see what you mean. At first glance I thought it was just checking that it didn't start with @ or whitespace.