Hashtag
Match hashtags (# followed by word characters) in social media posts, including accented Latin characters.
Try it in RegexPro →Available in
JavaScript / ECMAScript code
const re = new RegExp("#([\\w\\u00C0-\\u024F]+)", "g");
const input = "Loving #JavaScript and #regex!";
const matches = [...input.matchAll(re)];
console.log(matches.map(m => m[0]));Uses `String.prototype.matchAll` for global iteration (Node 12+ / all modern browsers).
Python (re) code
import re
pattern = re.compile(r"#([\w\u00C0-\u024F]+)")
input_text = "Loving #JavaScript and #regex!"
for m in pattern.finditer(input_text):
print(m.group(0))Stdlib `re` module — no third-party dependency. Works on Python 3.6+.
Go (RE2) code
package main
import (
"fmt"
"regexp"
)
func main() {
re := regexp.MustCompile(`#([\w\u00C0-\u024F]+)`)
input := `Loving #JavaScript and #regex!`
for _, match := range re.FindAllString(input, -1) {
fmt.Println(match)
}
}Uses `regexp.MustCompile` (panics on bad patterns at startup) and `FindAllString` for all matches.
Pattern
#([\w\u00C0-\u024F]+) (flags: g)Raw source: #([\w\u00C0-\u024F]+)
How it works
Examples
Input
Loving #JavaScript and #regex!Matches
#JavaScript#regex
Input
Post tagged #café and #naïveMatches
#café#naïve
Input
No hashtags hereNo match
—Common use cases
- •Social media post parsing and analytics
- •Hashtag extraction for content tagging pipelines
- •Trending topic aggregation
- •Moderation and content filtering systems
Related patterns
Base64 String
Text ProcessingMatch Base64-encoded strings, including proper padding with = and == characters.
Emoji (Unicode)
Text ProcessingMatch emoji characters across the main Unicode emoji ranges — requires the Unicode flag in JavaScript.
JSON Boolean / Null Literal
Text ProcessingMatch JSON `true`, `false`, and `null` literal values, with word boundaries to avoid partial matches.
Non-ASCII Character
Text ProcessingMatch runs of non-ASCII characters (anything outside U+0000–U+007F).