> For the complete documentation index, see [llms.txt](https://docs.metacopier.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.metacopier.io/tutorials/regex.md).

# Regex

A regex, or regular expression, is a sequence of characters that defines a search pattern. It is used for pattern matching within strings, allowing you to find specific text based on defined rules.

To learn how regex works take a look at this site [regexone.com ](https://regexone.com/)or if you are already familiar you can also check this online utility: [regex101.com](https://regex101.com/) (make sure to select Java on the left side)

## Copier filter

The copier filter can be used to allow only specific trades based on the **comment** or **magic number**. Here are some examples:

<table><thead><tr><th width="174">Type</th><th width="122">Regex</th><th>Description</th></tr></thead><tbody><tr><td>Comment</td><td>my EA</td><td>It copies only the trades that have "my EA" in the comment field</td></tr><tr><td>Comment</td><td>^my EA</td><td>It copies only the trades that have "my EA" in the <strong>beggining</strong> of the comment field</td></tr><tr><td>Comment</td><td>^my EA$</td><td>It copies only the trades that have <strong>exactly</strong> "my EA" in the comment field</td></tr><tr><td>Magic number</td><td>5</td><td>It copies only the trades that have "5" as magic number. Pay attention that "15" will also be copied.</td></tr><tr><td>Magic number</td><td>^5$</td><td>It copies only the trades that have "5" as magic number.</td></tr></tbody></table>

### Remarks

* Regex is **case sensitive**
* If you have multiple filters, they will be handled with the **OR operator**
* **cTrader**: the magic number filter is matched against the position **label**, but only **numeric** labels are supported. Labels containing letters or other non-numeric characters are ignored and the filter will never match. Use a numeric-only label on cTrader, or filter by the **comment** field instead.

## Symbol mapping

Here are some examples regarding the [symbol mapping](https://docs.metacopier.io/features/basic-features/symbol-mapping) and broker selection:

<table><thead><tr><th width="242">Regex</th><th>Description</th></tr></thead><tbody><tr><td>ICMarketsSC</td><td>The mapping is valid for all brokers that have ICMarketsSC in the broker name. This includes all live and demo brokers.</td></tr><tr><td>^ICMarketsSC-Demo02$</td><td>The mapping is valid for all brokers that matches <strong>exactly</strong> ICMarketsSC-Demo02</td></tr></tbody></table>

### Remarks

* Regex is **case sensitive**

## Permitted symbols

Here are some examples regarding the permitted symbols feature:

<table><thead><tr><th width="187">Type</th><th>Regex</th><th>Description</th></tr></thead><tbody><tr><td>Whitelist</td><td>eurusd</td><td>Only orders that includes "eurusd" and "EURUSD" (case insenstive) will be copied</td></tr><tr><td>Whitelist</td><td>eur</td><td>All order that includes "eur" or "EUR" (case insensitive) will be copied</td></tr><tr><td>Whitelist</td><td>^eurusd$</td><td>Only orders that matches <strong>exactly</strong> "eurusd" and "EURUSD" (case insenstive) will be copied</td></tr><tr><td>Blacklist</td><td>xau</td><td>All orders except orders that includes "xau" or "XAU" (case insenstive) will be copied</td></tr></tbody></table>

### Remarks

* Regex is **case insensitive**

## Telegram message filters

The [Telegram connector](/tutorials/telegram-signal-integration.md) lets you define **Include** and **Exclude** regex patterns to control which messages reach the AI. Filters are applied **before** the AI is called, so dropped messages do **not** count against your daily AI call limit (100/day on Basic, 200/day on Standard & Pro).

Use **either Include OR Exclude**, not both. Typing in one field clears the other list automatically.

* **Exclude** → drop noisy messages (announcements, promos, off-topic chatter) and let everything else through.
* **Include** → whitelist only messages matching at least one pattern and drop the rest.

Up to **60 patterns** per list. Each pattern is a separate chip, evaluated independently with substring match. If **any** pattern in the list matches the message, the list is considered a match.

### Examples

<table><thead><tr><th width="120">Type</th><th width="240">Regex</th><th>Description</th></tr></thead><tbody><tr><td>Exclude</td><td>announcement</td><td>Skip any message containing the word "announcement" (anywhere in the text).</td></tr><tr><td>Exclude</td><td>^promo:</td><td>Skip messages that <strong>start with</strong> <code>promo:</code> (e.g. <code>promo: 50% off</code>).</td></tr><tr><td>Exclude</td><td>\bgiveaway\b</td><td>Skip messages containing the <strong>whole word</strong> "giveaway" (won't match "giveaways" or "giveawayed").</td></tr><tr><td>Exclude</td><td>https?://</td><td>Skip any message containing a URL (http or https link).</td></tr><tr><td>Exclude</td><td>@\w+</td><td>Skip messages mentioning a Telegram username (e.g. <code>@admin</code>, <code>@support</code>).</td></tr><tr><td>Include</td><td>\b(buy|sell)\b</td><td>Only forward messages containing the whole word "buy" or "sell" (typical trading signal keywords).</td></tr><tr><td>Include</td><td>signal</td><td>Only forward messages containing the word "signal" anywhere in the text.</td></tr><tr><td>Include</td><td>🔔</td><td>Only forward messages containing the bell emoji (useful when the provider tags every signal with an emoji).</td></tr><tr><td>Include</td><td>\b(EURUSD|GBPUSD|XAUUSD)\b</td><td>Only forward messages mentioning one of these specific symbols.</td></tr><tr><td>Include</td><td>\b(tp|sl)\s*[:=]</td><td>Only forward messages that look like a real signal (contain <code>TP:</code>, <code>TP =</code>, <code>SL:</code> or <code>SL =</code>).</td></tr></tbody></table>

### Remarks

* Regex is **case insensitive** (you don't need to write both `buy` and `BUY`).
* Patterns use **substring match**: the regex doesn't need to match the whole message, just a portion of it.
* Invalid regex patterns are rejected when you press **Enter** or click **Add**.
* On the **Include** list, a message must match at least one pattern to be forwarded. Empty list = the include filter is off.
* On the **Exclude** list, a message matching any pattern is dropped. Empty list = the exclude filter is off.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.metacopier.io/tutorials/regex.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
