AG
Regex
AGREGEX
About
Cheat Sheet
Pattern Library
Guides
Contact
한국어
English
日本語
中文
Español
Português
Français
Deutsch
Русский
العربية
Bahasa Indonesia
← Pattern Library
PATTERN
Hashtag
Regex Pattern
Contact · Social
/
(?:^|\s)(#[A-Za-z0-9_]+)
/g
Copy
/(?:^|\s)(#[A-Za-z0-9_]+)/g
Contact · Social
Flags:
g
Description
Matches hashtags that come after whitespace or the start of a sentence and captures the tag, including the #, as a group. It reduces false positives like color codes (#fff) in the middle of a sentence. Useful for analyzing social media text.
Example Matches
#regex
#dev_tools
Test String
Check out today's tags #regex and #dev_tools.
Open this pattern in the tester
Other Patterns
Email
← Pattern Library