Skip to content

Instantly share code, notes, and snippets.

@teroyks
Last active September 1, 2025 08:56
Show Gist options
  • Select an option

  • Save teroyks/d1b76945b91e43205f26fc330aab4005 to your computer and use it in GitHub Desktop.

Select an option

Save teroyks/d1b76945b91e43205f26fc330aab4005 to your computer and use it in GitHub Desktop.
hashtag regex

Hashtag Regular Expression

A regex that matches 10 or more consecutive hashtags (after some other text). I use this to filter out spammy Mastodon posts.

Explanation

(\s+#[A-Za-z_]+){10,}
@teroyks
Copy link
Author

teroyks commented Sep 1, 2025

Does not match: #JustAFew #hashtags

This will match. #FirstHashtag #TheSecondOne #third #fourth #fifth #sixth #seventh #eight #ninth #tenth

@teroyks
Copy link
Author

teroyks commented Sep 1, 2025

This is the explanation from Regexer (in case the link above stops working).
73547

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment