EN
Open CopyPost

Replace Text and Links in Reposts Without Losing Formatting

3 min readRewritesBranding

Replace @mentions, links and signatures in Telegram posts you copy automatically. Plain rewrites, regular expressions with groups, and conditions.

Contents
  1. Plain rewrite
  2. Formatting stays intact
  3. Regular expressions with groups
  4. Conditional rewrites
  5. Order of rewrites
  6. Telegram limits

Copying a post is only half the job. Usually you also need to replace the source’s signature with your own, rewrite referral links or remove the “Subscribe to our channel” tail. That’s what pipeline rewrites are for when you copy messages from a Telegram channel.

Plain rewrite #

A “text → text” rewrite finds every occurrence and puts in the new value:

  • @source_channel → @my_channel
  • t.me/source_channel → t.me/my_channel

The same settings as filters: case-insensitive and word boundary. An empty replacement deletes the matched text.

Formatting stays intact #

Telegram stores bold text, links and spoilers separately from the text — as marks like “from character N, length M”. If you simply replace the text, the marks shift. CopyPost recalculates them after every rewrite: a bold word replaced with a longer one stays fully bold, and a link after it stays in place. It even accounts for emoji, which take up two “positions” in Telegram.

Regular expressions with groups #

A regex rewrite can rearrange parts of the matched text:

FindReplace withResult
(\d+)\s*USD$$$1“15 USD” → “$15”
(?P<user>\w+)@old\.com${user}@new.comchanges the domain in addresses
\n*Subscribe.*$(empty)removes the tail of the post

$1 and ${name} insert groups, $$ inserts a dollar sign. If the replacement refers to a group that doesn’t exist in the expression, the panel won’t let you save the pipeline — a typo won’t ruin your posts.

Conditional rewrites #

Each rewrite can have conditions — the same as filters. For example, add “#news” only to posts without photos, or change links only in posts that mention a partner. Conditions are checked against the original message, before any rewrites, so the order of rewrites doesn’t affect which of them fire.

Order of rewrites #

The rewrites themselves are applied one by one, from top to bottom: the second one sees the result of the first. Use the “↑” and “↓” buttons in the pipeline editor to change the order at any time.

Telegram limits #

A media caption is limited to 1024 characters, a text message to 4096. If the text gets longer after rewrites, CopyPost trims it neatly without breaking emoji or formatting.

Want to brand your images too? Read about watermarks on photos and videos.