'RegEx for twitter usernames
I need some help with regex for usernames which start with "@" and following rules:
Username includes only \w symbols.
Match if string has any non word character except "@", e.g.
- Match @username in
@username!&?()*^ - But don't match in
@username@username,@username!@usernameor@username!%^@(if string has at least one more "@").
- Match @username in
Don't match if string has any symbols before "@", e.g.
- Don't match @username in
not@usernameor!@username.
- Don't match @username in
For now i have:
(?<!\w)@(\w{4,15})\b(?!@)
Which excludes only \w symbols before and "@" if it stands only after username.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
