Regular expression for twitter username

前端 未结 9 2524
挽巷
挽巷 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

    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.

提交回复
热议问题