# Extract a value without writing a regular expression

> Select the value in a real message, and the platform writes the pattern and tests it against your twenty most recent messages.
> https://facteur.eu/en/help/pointeurs

A pointer extracts a value that [Extraction](extraction) does not find on its own: a
house identifier, a token in a format that is yours alone, or one of two codes present
in the same message.

You do not write a regular expression. **You select the value in a real message, and
the platform writes the pattern.**

## Create a pointer

1. In the inbox view, open a message that contains the value.
2. **Select the value** with the mouse. The editor proposes several patterns, ranked,
   each with the reason it sits there.
3. Pick a pattern, name it, save it.

The pointer then applies to **every new message in that inbox**, and you read it back
under the key you named:

```js
message.extract.orderCode;
```

## Choose the strategy

| Strategy | The pattern you get | When to pick it |
|---|---|---|
| `context` | anchored on the preceding words | **The recommended default.** Survives a layout redesign |
| `context-strict` | anchored on four words | The message holds several values of the same shape |
| `shape` | `\b(\d{6})\b` | The shape is unique in the message |
| `loose` | `\b(\d{5,7})\b` | The sender sometimes strips leading zeros |
| `literal` | the exact value | A string that never changes |

Patterns that capture **exactly** your selection, and **only once**, come first.

Take `context` if you are unsure: it anchors on the last literal words preceding the
value. A layout changes often, "your confirmation code is" much less so.

## Read the test result before saving

Before saving, the editor runs the pattern against your **twenty most recent
messages** and shows how many yield exactly one capture. Read that number: a pattern
that works on the message in front of you and fails on the ten before it is the one
that will break your CI run at three in the morning.

The test is executed by the service that receives your messages, so by the same
regular expression engine as production. The editor's green tick and the real
behaviour cannot diverge.

## What the engine refuses

Patterns are compiled by **RE2**. Two constructs do not exist, and the editor tells
you before saving rather than on the first message received:

- lookahead `(?=…)` and `(?!…)`;
- backreferences `\1`.

Almost everything you would do with a lookahead can be rewritten by anchoring on
context, which `context` already does.

## Write the pattern by hand

The pattern field stays editable if you would rather write it yourself. What you put
there goes through the same check: compiled by RE2, then run against your twenty most
recent messages. No path skips the test.
