Extrahieren hashtags from text
Hashtags starten mit # followed durch letters, Zahlen, und underscores. Lernen in extrahieren, validieren, und normalisieren hashtags von social media Text.
- 1
A hashtag is # followed by one or more word characters (letters, digits, underscores), with no spaces. Some platforms allow Unicode letters. The regex #[\w]+ (or #[^\s#]+ for more permissive matching) finds hashtags. Normalize by converting to lowercase and stripping the # for storage.
- 2 Regex-Tester →
Find all hashtags with #[\w]+ (ASCII) or #[\p{L}\p{N}_]+ (Unicode, requires u flag). Test against social media text: "Loving #WebDev and #JavaScript2024! #Frontend". The tool shows all matches.
- 3 Regex-Ersetzung →
Normalisieren hashtags: convert to lowercase, remove the # prefix, and deduplicate. Replace #([\w]+) with the lowercase version for consistent storage. Link hashtags to search pages by replacing #tag with <a href="/search?q=tag">#tag</a>.
Häufige Fragen
- What characters are allowed in hashtags?
- Most platforms allow letters, digits, and underscores. Some (Twitter/X, Instagram) allow Unicode letters (CJK, Arabic, emoji). Punctuation, spaces, and special characters end the hashtag. The # must be at the start or preceded by a space (otherwise it is part of a word, like C#).
- Should hashtags be case-sensitive?
- No — #WebDev and #webdev should be treated as the same tag. Normalize to lowercase for storage and comparison. Display in the original case if desired, but group by the lowercase form. This ensures consistent search and aggregation.