Aller au contenu
uencoder

Trouver et remplacer texte utilisant un regular expression

Search pour motifs (non juste literal chaînes) en texte et remplacer matches avec un template ce peut référence capture groups.

  1. 1

    Regex find-and-replace goes beyond literal substitution: it matches patterns (all email addresses, all numbers, repeated whitespace) and can use captured submatches in the replacement (e.g. swap first and last name).

  2. 2
    Remplacement par regex →

    Enter the regex pattern, flags (g for global, i for case-insensitive), and replacement template (use $1, $2 for capture groups). The tool shows all matches and the replaced output.

  3. 3
    Testeur de regex →

    Test the pattern first in the regex tester to confirm it matches what you expect before applying the replacement — this avoids catastrophic replacements on unexpected input.

Questions fréquentes

What is the difference between $1 and \1 in replacement?
$1 is the JavaScript replacement syntax; \1 is the sed/Perl syntax. Use $1 in JS-based tools. Named capture groups can be referenced as $<name> in modern JS.
My regex is too greedy — how do I limit matches?
Use non-greedy quantifiers (*?, +?) to match the shortest possible string, or replace .* with more specific character classes. Always test on edge cases — greedy regex is the most common source of unexpected replacements.

Workflows résolvant cette tâche

Outils associés