regex-replace

regex-replace changes parts of the input using a regular expression. You provide a Pattern (what to find) and an Output (how to rewrite the match). Every match of the pattern in the input is replaced by the output.

Under the hood it behaves like preg_replace(pattern, replacement, subject): the pattern (your regex) is applied to the current field value, and each match is substituted by the replacement string. By default, all matches are replaced.

UI fields and what they mean

  • Pattern: the regular expression used to find what should be replaced.
  • Output: the replacement string. You can reference capturing groups from the Pattern:
    • $1, $2 … → insert captured groups from the pattern (first group, second group, etc.).
    • $0 → inserts the entire match.
  • Condition: choose when to apply the replacement (e.g., Always, or only if a condition is met).

Example

Insert slash into number

Goal: turn 123412341111 into 12341234/1111.

  • Pattern: (\d{6})(\d{4})
  • Output: $1/$2

Explanation: the regex makes two groups – first 6 digits, then 4 digits. The replacement reinserts them with a / in between. Capturing groups are counted left-to-right starting at 1.

Common pitfalls & how to avoid them

  • Invalid pattern → if the regex itself is wrong (bad syntax, bad modifier), PalDock cannot process it and the field ends up blank.
  • No matches → if the pattern is valid but doesn’t match, the field value is returned unchanged (only invalid regexes cause blank output).
  • Greedy patterns → .* can consume too much. Use precise tokens or lazy .*? if needed.
  • Named groups → you can define them in the pattern (e.g. (?P<dd>\d{2})), but replacements still reference groups by number ($1, $2, …).

Replacement string tips

  • Prefer $1, $2 … in the replacement. \1, \2 also work, but $n is the recommended form
  • ${1}1 → use this form if you need “group 1” followed by the digit 1 (so it isn’t mistaken for group 11).
  • To output a literal $1 (not a backreference), escape the dollar in the replacement: \$1.
  • In PalDock you normally write the regex without slashes. If you must include /, escape it inside the pattern.
  • If you need flags, add them inline at the start of the pattern: Use the raw regex (no /…/ delimiters). Use inline flags like (?i) for case-insensitive if needed. Modifiers reference: i (case-insensitive), m (multiline), s (dot matches newline), u (UTF-8), etc.

Test your regex

AI tools can help generate regular expressions, but they may produce incorrect or overly complex patterns. Always test your regex before saving it. A free tool like regex101.com lets you quickly check how your pattern behaves, validate capturing groups, and confirm backreferences.

Reference

Related articles

Modify Field > combine
Modify Field > urldecode
Modify Field > urlencode
Modify Field > load-from-lead
Modify Field > from-base64
Modify Field > to-base64
Modify Field > modify-date
Modify Field > format-date
Modify Field > do-not-send
Modify Field > first-regex-match

Insights that
helps you grow