Zum Inhalt springen
Agentic Workflowdocs
v0.8.2Kostenlos installieren

knoten / builtin / datatransformation

Regex

Match, extract and replace text with a regular expression

Daten ErweiterungWeb-App

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

Pull a price, an id or any other fragment out of text, rewrite text, or check whether it contains a pattern.

Workflow · price-on-page-watch.awf 6 Schritte

Price On Page Watch: ein Workflow mit 6 Schritten, beginnend mit When the price changes und endend mit Remember this price.

In AWFlow öffnen

Regex runs a regular expression on the text of each incoming item and does one of four things, set by Operation:

  • Match: finds the first match.
  • Match all: finds every match and sends one item per match.
  • Replace: puts Replacement in place of the match.
  • Test: answers true or false.

Named groups do most of the work. A group such as (?<amount>[\d.,]+) becomes a field called amount on the outgoing item, so one Regex node can split a sentence into clean fields.

Matching runs with a 2-second time limit. A pattern that would take too long is stopped with an error instead of freezing the browser. The text can be up to 2,000,000 characters and the pattern up to 2,000.

  • Extract a price, order number or date from text you scraped from a page.
  • Split one text field into several fields with named groups.
  • Clean text, for example remove every non-digit from a phone number.
  • Branch on whether text contains something: run Test, then an IF on the result. For a simple “contains” check, IF alone is enough.
EinstellungTypWas es bewirkt
Operation ChoiceWhat to do with the pattern. Options: Match, Match all, Replace, Test. Standard: Match
Pattern TextThe regular expression, without surrounding slashes.
Flags Multiple choiceHow the pattern matches. Options: Ignore case (i), All matches (g), Multiline anchors (m), Dot matches newlines (s), Unicode (u).
Text ValueThe text to match against.
Source Field TextField holding the text, when the field above is left empty.
Replacement TextText put in place of each match. Use $1 or $<name> for groups.
Maximum Matches NumberMost matches collected before stopping. Standard: 1000
Include Input Fields ToggleKeep the incoming item’s fields alongside the result. Standard: On
Put Result In Field TextField holding the match, the replaced text, or the test result. Standard: match
  • Where the text comes from. Text wins if it is filled, for example with {{ $input.description }}. Otherwise the node reads the field named in Source Field (dots reach nested fields, such as product.title).
  • Replace changes only the first match unless you turn on the All matches (g) flag. Match all always finds every match, with or without the flag.
  • Replacement can reuse groups: $1 for the first group, $<amount> for a named group.
  • Maximum Matches can be raised to 10,000 at most.
  • Output

The result goes in Put Result In Field (match by default). With Include Input Fields on, the incoming fields stay on the item too.

  • Test: the result field is true or false.
  • Replace: the result field holds the new text.
  • Match: the result field holds the first match, or null. The item also gets matched (true or false), groups (a list of the numbered groups) and one field per named group. (?<currency>[£$€])(?<amount>[\d.,]+) on "Now $19.99" gives match: "$19.99", currency: "$", amount: "19.99".
  • Match all: one item per match, each with the same fields plus index, the match’s position in the text. If the match count hit Maximum Matches, each item also has truncated: true. If nothing matched, one item comes out with matched: false.

None. This node needs no connection and has no slots for other nodes.

  1. Get HTML from Link loads a product page, and HTML Extract reads the price text into a price field.
  2. Regex with Operation Match, Source Field price and Pattern (?<currency>[£$€])(?<amount>[\d.,]+).
  3. An IF checks whether {{ $input.amount }} is below your budget, as a number.
  4. On the true branch, a Browser Notification shows Now {{ $input.currency }}{{ $input.amount }}.
  • “This is not a valid regular expression: …”. The pattern has a syntax error, often an unclosed bracket or group. Write it without surrounding slashes: \d+, not /\d+/.
  • “This pattern took longer than 2000ms against this text and was stopped.” Nested repeats such as (a+)+ can take forever on some text. Make the pattern more specific, or match against less text.
  • “No text to match against. Fill in the Text field, or name the field holding it.” Both Text and Source Field are empty. Fill one of them.
  • “Field “…” does not exist on the incoming item.“ Source Field names a field the item does not have, or it is empty. Check the spelling.
  • matched is false but the text looks right. Matching is case sensitive by default: add the Ignore case (i) flag. For ^ and $ to work on every line, add Multiline anchors (m).
Get an alert when a price on a page drops Mittelstufe · 8 Min. Keine Einrichtung
  • Text / Formatter: ready-made text changes without writing a pattern.
  • HTML Extract: read values from a page by CSS selector.
  • Edit Fields: reshape the item after extraction.
  • Code: for logic a pattern cannot express.
Seite bearbeiten

Zuletzt aktualisiert:

Was this page useful?
Aria zu Regex fragen