Regular expression for twitter username

前端 未结 9 2465
挽巷
挽巷 2020-12-15 03:43

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

相关标签:
9条回答
  • 2020-12-15 04:23

    @[a-zA-Z0-9_]{0,15}

    You can use above regular expression to sort of the twitter usernames from a mixed set of data

    0 讨论(0)
  • 2020-12-15 04:23

    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.

    0 讨论(0)
  • 2020-12-15 04:25

    I think the correct regex is this /^@(\w){1,15}/g without the ? on @(at)

    0 讨论(0)
提交回复
热议问题