Skip to main content
Regexflux

Twitter/X Handle

beginner

Matches Twitter/X usernames starting with @.

socialtwitterhandlevalidation

Pattern

/@[a-zA-Z_]\w{0,14}/g

Try 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

LanguageSupport
JSFull support
PYTHONFull support
JAVAFull support
PHPFull support
GOFull 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);

Related Patterns