Text & everyday tools · Text Toolkit
Literal or regex? Why a dot in your search term can change every result
· Why it matters
find-and-replace regular-expressions text-editing
Explains which characters carry meaning in regular expressions, what goes wrong when 'a.b' or 'v1.2 (beta)' is treated as a pattern, and why a literal mode that escapes everything should be the default.
Searching for 'v1.2' and matching 'v102' — how a regex-first tool quietly turns punctuation into wildcards
A support agent changing `v1.2` in release notes may reasonably expect those four characters to identify one version label. With Regex enabled, however, the dot means any character except a line break. The pattern can therefore match `v102`, `v1-2` or `v1x2`, and Replace all can alter entries that were never part of the requested release.
This failure is quiet because the pattern is valid. There is no error message to distinguish a deliberate wildcard from punctuation copied out of a file name. The first warning may be an unexpectedly large replacement count. When the task is to replace known text exactly, punctuation should be data, not an instruction to the search engine.
The metacharacters — dot, brackets, parentheses, plus, star, question mark, pipe, caret, dollar and backslash, and what each does
In JavaScript regex mode, a dot is a wildcard; square brackets define a character class; parentheses create a group; plus, star and question mark control repetition; and a pipe offers alternatives. A caret and dollar sign anchor the pattern to the start or end of the whole text in this tool, because multiline mode is not enabled.
A backslash changes how the following character is read, and braces can express repetition counts. These symbols matter only in positions where the regex grammar treats them specially, so memorizing a list is less reliable than deciding which mode the job needs. If you are matching a supplied label, path fragment or file name, begin literally.
The metacharacters that matter in JavaScript regex mode
Literal mode makes the search mean what was typed. ToolAcre escapes regular-expression metacharacters before compiling the search, so `v1.2 (beta)` matches the dots, space and parentheses themselves. It does not turn the phrase into a wildcard followed by a capture group, and it still finds every exact occurrence across the text.
That escaping happens only on the search side. The replacement field still follows JavaScript replacement-string rules, where `$&` inserts the matched text and `$$` produces one dollar sign. Literal search is therefore the safe default for identifying text, but a replacement containing dollar signs still deserves a deliberate review before Replace all is selected.
Regex mode — when you want the power, and how to escape individual characters yourself
Regex mode is useful when several forms should match one rule. A pattern can target a range of digits, optional punctuation or alternatives without listing every source spelling. Turn Regex on only when that variability is intentional, then escape a special character with a backslash when it must retain its ordinary meaning, such as `.` for a dot.
The tool compiles the pattern with JavaScript regex syntax and always applies it globally. Clearing Case sensitive adds case-insensitive matching, but multiline, dot-all, sticky and unicode flags are not offered. Invalid syntax is reported without changing the text. A valid but overly broad pattern still runs, so compilation success is not proof of a safe match set.
Worked example — replacing 'config.yml (old)' across release notes in literal mode, then attempting the same in regex mode to see the difference
Consider release notes containing `Load config.yml (old)`, `Archive configXyml old` and `Keep config.yml (new)`. With Regex off, search for `config.yml (old)` and replace it with `config.yml (legacy)`. Exactly the first phrase changes because the dot and parentheses are escaped before the pattern is compiled.
Turn Regex on and submit the same unescaped search. The dot can consume another character, while the parentheses group `old` instead of matching literal parentheses, so the intended line no longer matches as written. A regex equivalent needs `config.yml (old)`. The literal version is shorter, clearer and better aligned with this exact-text task.
Common mistakes — trailing spaces in the search box, mixing up Whole word and literal, and forgetting the replacement count check
Trailing spaces are easy to overlook because the search field gives them little visual weight, yet literal mode preserves them. A search for `beta ` will not match `beta` at the end of a line. Check the field boundaries when a plainly visible term reports zero replacements, and avoid adding spaces merely to separate copied text from surrounding prose.
Whole word is not another name for literal. It wraps the compiled search in word boundaries, which are ASCII-based here and can fail around punctuation or accented terms. Also inspect the replacement count after every run and use Undo when it is surprising. The count is evidence about scope, not a decorative success message.
Common mistakes: spaces, Whole word boundaries and replacement syntax
This page does not attempt a full guide to regular-expression flags. ToolAcre uses global matching and optionally case-insensitive matching, while anchors still refer to the complete text rather than each line. Patterns copied from engines with inline flags, POSIX classes or different syntax may fail to compile or may mean something else in the browser.
Capture groups are supported, so the outline needs a correction rather than saying they are outside the tool. In Regex mode, groups can be referenced with `$1`, `$2` and later numbers in the replacement. That capability is separate from literal searching and from the limited flag controls; use it only when restructuring matched text is the actual goal.
Flags are limited here, while capture groups are supported in replacements
The practical rule is simple: leave Regex off when replacing a known version, file name, product label or sentence fragment. Literal mode escapes special characters automatically, preserving the punctuation that identifies the target. Enable Regex only when you can state what variation the pattern should accept and why an exact search is insufficient.
Before committing the edited release notes, compare the reported count with the number of changes you expected and inspect the result. ToolAcre leaves invalid patterns untouched and provides Undo for a valid pattern that reached too far. Those safeguards help, but choosing literal mode for literal work prevents the broad match before it happens.