You shouldn't only check for @ but for some additional rules to be sure, that it's not a email-address or something else.
Maybe something like this regex: s@([A-Za-z1-9!#?.:~]{2,})s*
This catch the username if:
- start with whitespace
- second character @
- then username can be characters, numbers and gilen special-characters
- must at least have a username length of 2 or more
- must followed by an whitespace
With that, and if you use global (/g) as regex-option, you should get all your user-names within an result-array.
Then you can check this Array against your user-database if they exist (or not).
Hope this helps you a bit.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…