Regex for Matching a Hashtag
Matches a # symbol followed by one or more word characters.
Published October 12, 2026
Matches a # symbol followed by one or more word characters.
Key points
- \w matches letters, digits, and underscores — hashtags with hyphens or other punctuation won't fully match
Example
#\w+