Twitter/X Handle
beginnerMatches Twitter/X usernames starting with @.
socialtwitterhandlevalidation
Pattern
/@[a-zA-Z_]\w{0,14}/gTry It
0 of 7 strings matched
Explanation
Matches @ followed by a letter or underscore, then up to 14 more word characters. Twitter handles are max 15 characters after the @.
Test Strings
Matching
- @elonmusk
- @_underscore
- @user123
Non-matching
- @
- noatsign
- @ space
- plain text
Language Compatibility
| Language | Support |
|---|---|
| JS | Full support |
| PYTHON | Full support |
| JAVA | Full support |
| PHP | Full support |
| GO | Full support |
Code Snippets
const regex = /@[a-zA-Z_]\w{0,14}/g;
const text = "your text here";
const matches = text.match(regex);
console.log(matches);