Skip to content
Facteur

Type at least two characters.

Extract a value without writing a regular expression

Select the value in a real message, Facteur suggests the pattern and tries it on your last twenty messages.

A pointer extracts a value that Extraction does not find on its own: a house identifier, a token in a format only you use, or one of two codes in the same message.

You do not write a regular expression. You select the value in a real message, and Facteur suggests the pattern.

Create a pointer

  1. In Messages, open a message that contains the value.
  2. Choose the part to read: Text, HTML or Subject.
  3. Select the value with the mouse. The editor suggests up to five patterns, the ones that capture exactly your selection first.
  4. Choose a pattern, give it a key (for example orderCode), and save.

The key starts with a letter, holds only letters, digits and _, and is 40 characters long at most. It is unique within the inbox.

The pointer then applies to every new message of the inbox. Messages already received do not change. You read the value under the key you named:

message.extract.orderCode;

Pointers also show in the message list, and copy with one click.

Choose the strategy

The patterns below are the ones you get for a six-digit code.

Strategy The pattern you get When to choose it
By the text before it (context) anchored on the two words before The safest choice. Survives a redesign of the layout
By the text around it (context-strict) anchored on four words The message holds several values of the same shape
By the shape of the value (shape) \b(\d{6})\b The shape is unique in the message
Tolerant (loose) \b(\d{5,7})\b The sender sometimes drops leading zeros
This exact value (literal) the value itself A string that never changes

Pick the text before it if you hesitate: it anchors on the last words before the value. A layout changes often, "your confirmation code is" much less.

Read the result of the trial before saving

Before saving, the editor tries the pattern on the last twenty messages of the inbox and shows how many give exactly one value. Read that number: a pattern that works on the message in front of you and fails on the previous ten is the one that will break your continuous integration at three in the morning.

When the pattern finds several values in a message, only the first is kept on reception, and the trial does not count that message as a success.

The save button stays inactive until the trial of the pattern on screen is back and valid. The trial and the reception use the same engine, so the tick in the editor and the real behaviour cannot diverge.

What the engine refuses

The engine refuses what RE2 cannot do. These constructs do not exist, and the editor tells you before you save rather than at the first reception:

  • lookaheads (?=…) and (?!…), and lookbehinds (?<=…) and (?<!…);
  • the backreference \1;
  • possessive quantifiers, atomic groups, recursion and conditional subpatterns.

Almost anything you would do with a lookahead can be rewritten by anchoring on the context, which the "by the text before it" choice already does. A pattern is 512 characters long at most, and a pattern whose evaluation takes too long captures nothing, without ever losing the message.

Write the pattern by hand

The editor offers Write the pattern by hand if you prefer. What you put there goes through the same check: the constructs above are refused, then a trial on your last twenty messages. No path skips the trial.

Delete a pointer

Under an open message, the Pointers of this inbox list shows each pointer with its value on the most recent message. The Delete button removes the pointer: new messages no longer carry its key.