Regex for Hashtag

Matches a social media hashtag like #OpenAI.

^#[A-Za-z0-9_]+$

Proof it works

5/5 sample tests passed · compiles: true

SampleShould matchResult
#OpenAI yes pass
#travel_2026 yes pass
# no pass
no-hash no pass
# space no pass

Try your own input

Related patterns