@mention regex pattern

Copy and test a JavaScript regex for @mentions, with examples and a one-click link to the regex tester.

@mention regex pattern

Validate whole value

Use anchors to check whether the complete value matches.

Regex: ^@[A-Za-z0-9_]{1,30}$

Flags: -

Search in text

Find matching fragments inside a larger block of text.

Regex: @[A-Za-z0-9_]{1,30}

Flags: g

Examples that match

  • @alice_dev
  • @team42

Examples that do not match

  • alice_dev
  • @two words