I need a javascript regular expression to match twitter usernames.
The username is entered by the user while signing up, so I don\'t want to distract them with too m
@[a-zA-Z0-9_]{0,15}
You can use above regular expression to sort of the twitter usernames from a mixed set of data
To exclude "non-latin" characters, you have to use: ^@?([a-zA-Z0-9_]){1,15}$
. Because, \w
accepts "any word characters". And non-latin characters qualifies this condition. So, it matches even üö
like Turkish characters as well.
I think the correct regex is this /^@(\w){1,15}/g
without the ? on @(at)