Replace text parser

Configuration options

  • Text to replace - The text or pattern to search for in the current field value.
  • Text to place - The replacement text. Leave this field empty to remove the matched text. Escape sequences such as \n, \r and \t can be used.
  • Use Regex - When enabled, Text to replace is interpreted as a regular expression. Capture groups can be reused in Text to place with references such as $1, $2 and so on.

Remove a fixed value

Leave Text to place empty when a known string should be removed.

Example source:

Price: $24.99

Configuration:

Text to replace: Price:
Text to place:
Use Regex: No

Result:

$24.99

If the result contains unwanted leading or trailing whitespace, add a Remove whitespaces parser after Replace text.

Replace text with another value

Use a direct replacement when a known label or symbol needs to be normalized.

Example:

Source: In stock
Text to replace: In stock
Text to place: available
Result: available

Use regular expressions

Enable Use Regex when the text varies but follows a predictable pattern.

Regular expressions are useful for:

  • Removing variable prefixes or suffixes.
  • Reformatting values with capture groups.
  • Replacing text only when it appears at the beginning or end of a field.
  • Normalizing several variations of the same value.

Do not add surrounding / characters around the regular expression.

Use capture groups in the replacement

Capture groups allow parts of the original text to be retained while the value is reformatted.

Example source:

Color
Green

Configuration:

Text to replace: ([^\n]+)[\s\n]+([^\n]+)
Text to place: $1: $2
Use Regex: Yes

Result:

Color: Green

$1 refers to the first capture group and $2 to the second.

Replace the complete field

A regular expression that matches the complete value can be used to replace the field with a fixed value.

Text to replace: [\s\S]+
Text to place: available
Use Regex: Yes

Result:

available

This can be useful when the presence of any source value should be converted into a standard output value.

Add a domain to relative URLs

When a scraped URL contains only a relative path, Replace text can add the domain only when the value begins with /.

Example:

Source: /products/widget-123
Text to replace: ^/
Text to place: https://example.com/
Use Regex: Yes

Result:

https://example.com/products/widget-123

This approach avoids adding the domain to values that are already complete URLs.

Parser order matters

Replace text operates on the value produced by the parser before it. If several transformations are required, order them according to the expected input.

For example:

Raw HTML
→ Replace text to preserve spacing
→ Strip HTML
→ Remove whitespaces

Changing this order can produce a different result.

When to use Replace text instead of Regex match

Use Replace text when the original field should be modified. Use Regex match when only a specific substring should be extracted from the source value.

If the transformation becomes difficult to understand as one large regular expression, use several simple parser steps instead.

Troubleshooting

  • If nothing changes, confirm whether Use Regex matches how the pattern was written.
  • If a capture group returns empty text, confirm that the group exists in the expression and that the source value matches the expected structure.
  • If replacement removes spacing between HTML elements, use Replace text before Strip HTML to insert the spacing you need.
  • Use the Parser preview after each change to confirm the result before adding another parser.

Related