# Regular expressions in filters and replacements

Language: en
Canonical: <https://flowin.click/en/articles/regular-expressions>
Published: 2024-08-21T08:47:17+01:00
Modified: 2026-10-21T08:32:48+01:00

A regular expression describes the text you want to find. Instead of specifying one exact phrase, you define a pattern: for example, the word “Request” followed by any number. The number can change in every message, and the pattern will still find the fragment you need.

You can use this to find dates, links, individual words, entire lines and almost any combination of text that can be described by a rule. A few simple symbols let you account for changing values, choose between alternatives and skip what you do not need. This type of search can do much more than a simple word search.

![Finding matching text fragments with a pattern](<https://flowin.click/wp-content/uploads/2026/10/cf-da8cc01b43e113428f944f35.webp>)

Article contents

- [What regular expressions can do](<https://flowin.click/en/articles/regular-expressions#headline-6-324>)
- [How to read a regular expression](<https://flowin.click/en/articles/regular-expressions#reading-pattern>)
- [Regular expression syntax](<https://flowin.click/en/articles/regular-expressions#headline-11-324>)
- [Search settings in FLOWIN](<https://flowin.click/en/articles/regular-expressions#flowin-flags>)
- [Ready-to-use patterns](<https://flowin.click/en/articles/regular-expressions#headline-45-640>)
- [Frequently asked questions](<https://flowin.click/en/articles/regular-expressions#faq>)

## What regular expressions can do

Regular expression support in FLOWIN filters and replacements lets you:

- Add any text to the beginning or end of messages.
- Filter messages containing links.
- Remove links, phone numbers, email addresses and other contact information from copied messages.
- Filter long messages or, conversely, only short ones.

“Regexp” mode

In the filter or replacement settings, “Regexp” mode next to the “Search” field enables regular expression searches. The pattern itself goes in this field. The guides to [filters](<https://flowin.click/en/articles/filtering-forwarded-messages>) and [replacements](<https://flowin.click/en/articles/replacements-in-forwarded-messages>) explain how to create a filter or replacement and apply it to a forward.

[![Regexp mode next to the Search field in the replacement settings](<https://flowin.click/wp-content/uploads/2026/10/cf-ef59cdaf7b2e906ba9eef962.webp>)](<https://flowin.click/wp-content/uploads/2026/10/cf-ef59cdaf7b2e906ba9eef962.webp>)

“Regexp” in the replacement settings.

## How to read a regular expression

Let’s start with the pattern ` Request #\d+ `. It finds both ` Request #125 ` and ` Request #8072 `, even though the numbers are different. Read it from left to right:

- ` Request # ` looks for those exact letters, the space and the number sign.
- ` \d ` stands for any digit from 0 to 9.
- ` + ` requires one or more of those digits in a row.

The fragment found is called a match. In the message ` Request #125 accepted `, the match is ` Request #125 `, while the word ` accepted ` remains outside it. In a filter, a match helps determine whether the message meets the condition; in a replacement, it identifies the fragment to change.

Ordinary letters and spaces in a pattern are matched exactly as written. Special symbols define the rules. The basic notation is explained below, followed by ready-to-use examples for different tasks.

## Regular expression syntax

To start using regular expressions, you need to know the syntax: what particular symbols mean.

### Basic symbols

- ` ^ ` marks the beginning of the text.
- ` $ ` marks the end of the text.
- ` . ` matches any character, including a line break.
- ` \d ` matches a digit from 0 to 9.
- ` \w ` matches a Latin letter, a digit or an underscore.
- ` \n ` represents a line break.
- ` \t ` represents a tab.
- ` \s ` matches a regular space, a tab, a line break, a carriage return or a form feed.
- ` \b ` checks for a word boundary, for example between a letter and a space. It does not add a character to the match.

### Quantifiers

Quantifiers specify how many times the character or group before them repeats. A group combines several characters in parentheses.

- ` * ` means zero or more times.
- ` + ` means one or more times.
- ` ? ` means zero or one time.
- ` {5} ` means exactly five times.
- ` {1,5} ` means one to five times.
- ` {1,} ` means one or more times.
- ` {0,5} ` means zero to five times.

For example:

- ` a+ ` matches ` a `, ` aa `, ` aaa ` and so on.
- ` .* ` matches any text, even an empty string.
- ` ab{3} ` matches ` abbb `.

### Groups

Parentheses ` ( ) ` combine characters into a group. Groups are most often used with [quantifiers](<https://flowin.click/en/articles/regular-expressions#quantifiers>) or the vertical bar ` | `, which represents logical OR.

For example:

- ` ((Bob)|(Alice)) ` matches both ` Bob ` and ` Alice `.
- ` (abc){3} ` matches ` abcabcabc `.

### Character sets

Square brackets ` [ ] ` define a set of characters. Inside them, you can list characters as follows:

- ` [а-яё] ` matches any letter of the Russian alphabet.
- ` [абвгд] ` or ` [а-д] ` matches one of the letters ` а `, ` б `, ` в `, ` г ` or ` д `.
- ` [a-z] ` matches any Latin letter from ` a ` to ` z `.
- ` [0-5] ` matches any digit from 0 to 5.

The symbol ` ^ ` at the beginning of a set represents logical NOT:

- ` [^а-яё] ` matches any character except a letter of the Russian alphabet.
- ` [^a-z] ` matches any character except a Latin letter from ` a ` to ` z `.
- ` [^\s] ` matches any character that is not included in ` \s `.

In FLOWIN, ` \w ` does not include Cyrillic letters. ` [а-яё] ` covers the Russian alphabet, including ` ё `. The range ` [а-я] ` does not include that letter.

### Escaping characters

To use a special character as ordinary text rather than part of the syntax, put a backslash ` \ ` before it. This is called escaping.

For example:

- ` :\) ` matches ` :) `. Here, the parenthesis represents a literal parenthesis rather than a group.
- ` who\? ` matches ` who? `. Here, the question mark does not specify the number of repetitions.

## Search settings in FLOWIN

Flags change the general search rules: for example, whether uppercase and lowercase letters are treated differently. Some settings are already enabled in FLOWIN, so the same pattern may behave differently in a third-party tester with its default settings.

The flags are already configured

Filters and replacements have ` IgnoreCase (i) `, ` Singleline (s) `, ` RE2 ` and ` Unicode ` enabled. You do not need to add them manually to every pattern. Here is what matters in practice:

- ` i ` makes searches case-insensitive: ` cat ` finds both ` Cat ` and ` CAT `.
- ` s ` allows the dot ` . ` to match a line break. This means ` .* ` can match several lines at once.
- Multiline mode ` (m) ` is off by default: ` ^ ` and ` $ ` refer to the beginning and end of the entire message, rather than each line.
- ` RE2 ` determines certain aspects of the syntax: ` \d ` matches digits 0–9, while ` \w ` matches only Latin letters, digits and underscores. Enabling ` Unicode ` does not add Cyrillic letters to ` \w `.

You do not need to change any settings for the examples below. If you test them in another service, take these settings into account: matching flag names do not guarantee identical behavior across different engines.

## Ready-to-use patterns

Choose a task and copy the pattern into the “Search” field with “Regexp” mode selected. The examples show exactly which text is matched. What happens to the message afterwards depends on the filter or replacement you have configured.

### A request number that changes each time

Find a request without knowing its number in advance.

Pattern:  
` Request #\d+ `

Text: ` Request #125 accepted. Request #8072 awaiting a response. `

Matches: ` Request #125 `, ` Request #8072 `.

The text “Request \#” stays the same, while ` \d+ ` matches one or more digits in a row. The space before \# is also part of the pattern. “Request \#ABC” will not match.

### A message containing only six digits

Select messages containing exactly a six-digit code.

Pattern:  
` ^\d{6}$ `

Text: ` 482901 `

Matches: ` 482901 `.

The beginning and end delimit the entire message, while ` {6} ` specifies six digits. “Code: 482901”, “48290” and “482901 ” with a trailing space will not match.

### One of several text alternatives

Find messages mentioning either of two statuses.

Pattern:  
` done|cancelled `

Text: ` Done: the file has been sent. Another task has been cancelled. `

Matches: ` Done `, ` cancelled `.

The vertical bar means “or”. Letter case does not matter. Without word boundaries, the pattern also finds “done” inside “undone”.

### A whole word, without matches inside other words

Find the word “cat”, skipping “catfish” and “bobcat”.

Pattern:  
` \bcat\b `

Text: ` Cat, catfish and bobcat. `

Matches: ` Cat `.

` \b ` on both sides checks the word boundaries. Spaces and punctuation can separate the word from the surrounding text; they are not included in the match.

### A date in day.month.year format

Find a date with a two-digit day and month and a four-digit year.

Pattern:  
` \d{2}\.\d{2}\.\d{4} `

Text: ` Meeting on 16.10.2026 at 12:00. `

Matches: ` 16.10.2026 `.

` \. ` represents a literal dot, rather than any character. The pattern checks the format, not the calendar: “99.99.2026” will also match.

### Hashtags in Russian and English

Find hashtags made up of letters, digits and underscores.

Pattern:  
` #[а-яёa-z0-9_]+ `

Text: ` #Новости #release_2 #всё_готово `

Matches: ` #Новости `, ` #release_2 `, ` #всё_готово `.

The \# is followed by one or more characters from the set. A space or hyphen ends the match: in “\#план-дня”, only “\#план” is found.

### Mentions in @username format

Find text that looks like a user or channel mention.

Pattern:  
` @[a-z0-9_]{3,} `

Text: ` Author: @news_room. Another one: @ab. `

Matches: ` @news_room `.

The @ must be followed by at least three Latin letters, digits or underscores. The pattern looks for the format; it does not check whether the user exists. It can also match part of an email address.

### Links starting with http:// or https://

Find a web address written out with its protocol.

Pattern:  
` https?:\/\/[^\s]+ `

Text: ` Open https://example.org/page and http://example.org `

Matches: ` https://example.org/page `, ` http://example.org `.

The letter s is optional. After //, the pattern takes characters up to the next space or another separator included in ` \s `. An address without a protocol will not match, while a comma or dot immediately after the address may be included in the match.

### A phone number written as +7 and ten digits

Find a number written without parentheses, spaces or hyphens.

Pattern:  
` \+7\d{10} `

Text: ` Contact: +79991234567 `

Matches: ` +79991234567 `.

` \+ ` looks for a literal plus sign, while ` \d{10} ` specifies exactly ten digits after the 7. “+7 (999) 123-45-67” will not match. This checks the format, not whether the number exists; a match is also possible within a longer sequence of digits.

### Messages that begin with a particular label

Find the label “Important:” only at the very beginning of a message.

Pattern:  
` ^Important: `

Text: ` IMPORTANT: the meeting has been rescheduled. `

Matches: ` IMPORTANT: `.

^ checks the beginning of the entire text. There will be no match in “Update: Important: the meeting has been rescheduled”. A label at the beginning of the second line will not match either, because multiline mode is off by default.

### Extra spaces between words

Find two or more regular spaces in a row so you can replace them with one.

Pattern:  
` [ ]{2,} `

In the text ` Text··with···spaces `, two groups will be found: two spaces and three spaces. The ` · ` symbol here only shows a regular space; you do not need to type it.

There is a regular space inside the square brackets, and ` {2,} ` requires at least two in a row. To remove extra spaces, replace the matched fragments with a single space. This pattern does not affect line breaks.

### Short messages of up to a hundred characters

Select non-empty messages between 1 and 100 characters long.

Pattern:  
` ^.{1,100}$ `

Text: ` Short message `

Matches: ` Short message `.

The dot counts any character, including spaces and line breaks. The braces set the limits, while ^ and $ require the entire message to be checked. An empty message or text longer than 100 characters will not match. A composite emoji may count as several characters.

The list will grow. You can send suggestions for new patterns to support at [@value\_maker](<https://t.me/value_maker>).

Testing your own pattern

You can use [regex101.com](<https://regex101.com/>) to test your own regular expressions. Its search settings may differ from FLOWIN’s, so before using a pattern with a working forward, you need to check it on test messages: both ones that should match and ones that should not.

## Frequently asked questions

 

**When is “Text” or “List” enough, and when do I need “Regexp”?**

“Text” mode works for one known phrase, while “List” lets you specify several alternatives. You need “Regexp” when text changes according to a rule: for example, when the word “Request” is followed by a different number each time. It also lets you specify word boundaries or a character count. What happens to a matched message is configured separately in the [filter](<https://flowin.click/en/articles/filtering-forwarded-messages>) or [replacement](<https://flowin.click/en/articles/replacements-in-forwarded-messages>).

 

**Why does a pattern from an online tester behave differently in FLOWIN?**

The result depends on the engine and search settings. FLOWIN filters and replacements already have IgnoreCase, Singleline, RE2 and Unicode enabled, while Multiline is off by default. Searches are therefore case-insensitive, the dot can match a line break, and ` ^ ` and ` $ ` refer to the entire message. Compare the [search settings](<https://flowin.click/en/articles/regular-expressions#flowin-flags>) and test the pattern in FLOWIN on messages that should match and ones that should not.

 

**Why does .\* match several lines?**

FLOWIN has Singleline enabled, so the dot also matches a line break. This means ` .* ` does not have to stop at the end of the first line. To find text up to the next line break, you can use ` [^\r\n]+ `: this pattern matches one or more characters other than a carriage return or a line break.

 

**Why does \\w not match Russian letters?**

With FLOWIN’s search settings, ` \w ` covers Latin letters, digits and underscores. For Russian letters, use ` [а-яё] `, or ` [а-яё]+ ` for a sequence of those letters. You need to specify the letter ` ё ` separately: the range ` а-я ` does not include it. You do not need to distinguish uppercase and lowercase letters, because the search is already case-insensitive.

 

**How do I find a whole word rather than part of another word?**

Add ` \b ` on both sides of the word. For example, ` \bcat\b ` finds “Cat” in “Cat, catfish and bobcat”, but skips the other two words. The boundaries check the word’s position; spaces and punctuation are not included in the matched fragment.

 

**Does the date pattern in the example check whether the date exists?**

No. The expression ` \d{2}\.\d{2}\.\d{4} ` only checks the format: two digits, a dot, two digits, a dot and four digits. It therefore finds both ` 16.10.2026 ` and ` 99.99.2026 `. This example is suitable for finding fragments that look like dates, but it does not confirm that the day and month are valid.

 

**What should I check if a regular expression finds nothing?**

First, make sure “Regexp” is selected next to the “Search” field. Then compare the pattern with the original text: spaces, line breaks and literal characters also affect the match. For example, ` Request #\d+ ` requires a space before \# and digits after it, so it will not find ` Request#125 ` or ` Request #ABC `. Also check the boundaries ` ^ ` and ` $ `: by default, they refer to the entire message. Start with a simple fragment and add conditions one at a time, checking the result after each addition.
