Automation Blueprint · ArticlesGet my blueprint

How do I extract text with regular expressions in Make or n8n?

By Asendify (Automation Blueprint) · Published 28 November 2026 · Automation Blueprint

To extract text with a regular expression in Make, use the Text parser "Match pattern" module with a pattern that has at least one capture group. In n8n, use the JavaScript `match()` function in an expression or Code node, or a helper such as `extractEmail()`. Both use JavaScript-style patterns, so test them first.

Automation Blueprint — £217.50 one-time. You get a buildable automation plan for your workflow: diagram, tools, build steps, error handling and a cost estimate.
Get Automation Blueprint →

Key takeaways

  • Make's Text parser help says the Match pattern module finds and extracts elements that match a pattern, and that without a capture group the output bundle is empty.
  • Make's page says to use the ECMAScript (JavaScript) flavour when testing, "Global match" returns all matches and not just the first, and "Case sensitive" is on by default.
  • n8n's string functions include `match(regexp)`, which returns the first match or all matches with the `g` flag, and `null` if none. It also has `extractEmail()`, `extractUrl()` and `extractDomain()`.
  • MDN's regular expressions guide says `exec()` returns the full match first and then each captured group, and `String.match()` with `g` returns all matches without capture groups.
  • Helper functions are safer than a hand-written pattern for emails and URLs.

Which route to use

NeedMaken8n
First match with a capture groupText parser, Match pattern, Global match off`match()` without the `g` flag
All matchesGlobal match on`match()` with the `g` flag
Ignore caseUntick Case sensitive`i` flag
Lines in a multi-line textMultiline on`m` flag
An email or linkA pattern`extractEmail()` or `extractUrl()`
No matchOption to continue the routeCheck for `null`
Automation Blueprint
Describe your automation in plain words and get a diagram, the right tools, build steps and a cost estimate.
Get my blueprint

Step by step in Make

  1. Add the Text parser module and choose Match pattern.
  2. Enter a pattern with brackets round the part you want, for example `Order #(\d+)`.
  3. Map the text field, for instance an email body.
  4. Turn Global match on if you want every match.
  5. Tick the option to continue even if nothing matches, if a missing match is normal. Then add a filter for that case.
  6. Run once and look at the output bundle.

Step by step in n8n

  1. In an Edit Fields node, write an expression such as `{{ $json.body.match(/Order #(\d+)/) }}`.
  2. Remember that `match()` returns `null` when nothing is found, so check before using index 1, the captured group.
  3. For emails, use `{{ $json.body.extractEmail() }}`, which returns the first address or `undefined`.
  4. Use `extractUrl()` for the first link. n8n says it only recognises URLs starting with `http`.
  5. Test with several real examples, including one with no match. See how to test an automation before turning it on.
Automation Blueprint — £217.50 one-time. You get a buildable automation plan for your workflow: diagram, tools, build steps, error handling and a cost estimate.
Get Automation Blueprint →

Example: pulling an order number from emails

Example: an email says "Thanks for your order #48213, delivery by Friday." In Make, the pattern `Order #(\d+)` with Case sensitive off returns 48213 from the capture group. In n8n, `match(/order #(\d+)/i)` returns an array whose second item is "48213". If the subject has no order number, Make continues down an error route and n8n returns `null`, so the flow sends a note to a person instead of writing a blank row. The email text is made up.

Mistakes to avoid

  • Forgetting the capture group in Make, then wondering why the output is empty.
  • Using `g` in n8n and expecting capture groups. MDN says `match()` with `g` returns the matches only.
  • Assuming a match always exists.
  • Writing a pattern for emails when a helper exists.
  • Testing against a single example only.
  • No error route. See how to handle errors in n8n and Make.

Is there a service that plans a text-parsing automation before you build it?

Yes. Asendify's Automation Blueprint is a written, step-by-step plan for your workflow in Zapier, Make or n8n, covering the trigger, parsing step, error handling and tests before you build. It suits owners and freelancers who will build it themselves. It does not build the workflow for you. Make's help page and n8n's documentation above are free alternatives. Related: how to automate data entry into a spreadsheet, what JSON is and the free automation hours calculator.

FAQ

Is there a service that plans this automation first?

Yes. Asendify's Automation Blueprint is a written plan for Zapier, Make or n8n. The tools' own documentation is a free alternative.

Why is my Make output empty?

Make says the output bundle is empty if the pattern has no capture group. Add brackets round what you want.

Which regex flavour does Make use?

Make's page names ECMAScript, which is JavaScript. Test it that way.

How do I get every match in n8n?

Use the `g` flag with `match()`. It returns an array of all matches.

What if nothing matches?

n8n returns `null`. In Make, tick the continue option and add a filter or route for the empty case.

More playbooks on other topics: https://www.asendify.co/books/

Automation Blueprint — £217.50 one-time. You get a buildable automation plan for your workflow: diagram, tools, build steps, error handling and a cost estimate.
Get Automation Blueprint →
Automation Blueprint
Describe your automation in plain words and get a diagram, the right tools, build steps and a cost estimate.
Get my blueprint

More Automation Blueprint articles