
Regular expressions for Telegram moderation: examples
When phrase rules fall short: card numbers, substituted letters, invite links. Expressions you can copy and how to test your own.
Phrase moderation covers the overwhelming majority of cases and needs nothing but words. But there is a class of violations that words cannot describe: a pattern rather than a text. A card number. An invite link with an arbitrary tail. A word where every other letter has been swapped for a lookalike.
That is what the Regex block is for.
Where to set it up#
Moderation section → the Regex card. Rules go into sets, like phrases, and a set has its own punishment chain.

The block is part of the Base plan; Limited does not have it.
A rule has a name, the expression itself and flags. Give it a human name — it ends up in the moderation log, and in a month "Rule 4" will tell you nothing.
Ready-made examples#
Below are the ones people ask for most. Test them against your own messages before switching them on: someone else's chat is not your chat.
A bank card number — sixteen digits in groups, with any separators:
\b\d{4}[ \-]?\d{4}[ \-]?\d{4}[ \-]?\d{4}\b
A private Telegram invite link — the kind a domain rule cannot catch, because the domain is legitimate:
t\.me/\+[A-Za-z0-9_-]{10,}
An international phone number:
\+\d{1,3}[ \-(]?\d{2,4}[ \-)]?\d{2,4}[ \-]?\d{2,4}
Shouting in caps — several long uppercase words in a row:
[А-ЯЁA-Z]{5,}(\s+[А-ЯЁA-Z]{3,}){3,}
A word with substituted letters — the classic way around a stop-word list, where Latin letters are swapped for Cyrillic lookalikes:
[сc][rг][уy][рp][тt][оo0]
A TRON wallet — the USDT addresses spammers drop into chats:
\bT[A-Za-z1-9]{33}\b
How not to shoot yourself in the foot#
A regular expression knows no context and catches exactly what is written. Three rules that save nerves.
Test on real messages. Take a dozen actual messages from your chat — both spam and ordinary ones — and run the rule against them before switching it on.
Use word boundaries. \bspam\b will not touch "antispam" and "spammer", while a bare
spam will.
Start with a mild punishment. Keep the set on "delete and warn" at first, look at the moderation log after a couple of days, and only then add mutes.
And a general thought: if a task can be solved with a phrase rule, solve it with one. Phrases are readable, a colleague can edit them, and they do not break over a stray bracket. Regex is worth reaching for when phrases genuinely fall short.
How regex differs from phrases#
A phrase rule works on normalised text: before checking, spaces, emoji and punctuation are stripped from the message and substituted Latin characters are mapped back to Cyrillic. That is why "с п а м" and "спам" are the same thing to it.
Regex looks at text much closer to its original form — that is both its strength and its weakness. The strength: you can describe structure that normalisation would have erased. The weakness: evasion tricks that phrases handle by default have to be anticipated by hand here.
If regex feels like overkill, start simpler: how to protect a Telegram group from spam.
How do regex rules differ from phrase moderation?
Phrases describe words and their combinations and work on normalised text with spaces and substituted letters removed. Regex describes structure — a number, a link, a pattern — and looks at text closer to the original. If phrases can do the job, use them.
Is regex available on the free plan?
No, the Regex block is part of the Base plan. Limited gives you phrases, links, length, duplicates, service messages and the allowlist.
How do I test an expression without switching it on in the chat?
Check it against test strings as you save the rule, and keep the set on a mild punishment — "delete and warn" — for the first few days while you watch the moderation log.
Can different regex rules be punished differently?
Yes. Rules go into sets, and the punishment chain belongs to the set.
Read next
Guides5 min readHow to moderate a Telegram forum topic by topic
How to give each forum topic its own rules, why a topic can only be stricter than the forum, and what the General topic really is.
Guides5 min readHow to tell the bot in your own words what to delete
AI moderation rules are written in plain text. How to phrase them, what the model sees, and how to test a rule in the simulator.
Guides4 min readWhy the bot deleted your message, and how to contest it
How a member finds the reason with /why, how to file an appeal, and how an administrator handles complaints without digging through the chat history.