免费工具

查找和替换

使用普通匹配或正则表达式替换文本,支持大小写、全局和多行选项。




What the Find & Replace tool does

This tool searches a block of text for a pattern and swaps every match for something else, with the options that make bulk edits reliable: plain (literal) matching or full regular expressions, case-insensitive matching, replace-all versus replace-first, and multiline mode. It reports how many replacements it made, so you always know the change did what you expected. Reach for it whenever a manual edit would be tedious or error-prone — renaming a term across a long document, reformatting a list, stripping or rewriting parts of log lines, converting delimiters, fixing a typo that appears dozens of times, or restructuring data with capture groups. It is the same find-and-replace you know from an editor, but instant, in the browser, and with regex power on tap.

How it works, technically

When you use plain mode, the tool treats your search text literally: it escapes any characters that would otherwise have special regex meaning (such as ., *, ( or ?), so “a.b” matches the exact string a.b and nothing else, and your replacement is inserted verbatim. When you enable regular-expression mode, your pattern is compiled directly, and the replacement can reference capture groups with $1, $2 and so on — so a pattern like (\w+)@(\w+) with a replacement of $2:$1 rewrites user@host into host:user. The checkboxes map straight onto standard regex flags: “replace all” adds the global flag g, “case-insensitive” adds i, and “multiline” adds m so that the anchors ^ and $ match the start and end of each line rather than the whole text. If your regex is malformed, the tool catches the error and tells you the pattern is invalid instead of failing silently.

Uses, tips and gotchas

Regular expressions are what turn this from a convenience into a power tool, but they reward a little care. Anchors behave very differently with multiline on or off: ^ matches only the very start of the text by default, but every line’s start once multiline is enabled. The dot . does not match newlines, so patterns that need to span lines require a different construct. Remember that with “replace all” off, only the first match changes even though the tool still shows you how many matches exist in total, which is handy for previewing scope before you commit. Test on a copy first when a pattern is greedy — .* can grab far more than you intended. And if you only need a literal swap, leave regex mode off so that special characters in your search or replacement are treated as ordinary text.

  • Bulk renaming — change a product name, variable or term everywhere it appears.
  • Reformatting data — convert commas to tabs, reorder fields with capture groups, or wrap values.
  • Cleaning logs and exports — strip timestamps, mask tokens, or normalise inconsistent formatting.
  • One-off regex work — a quick place to test a pattern before pasting it into your own code.

It all runs locally, so your text is private. The matching and replacing happen entirely in your browser through local JavaScript — the text you paste, your patterns and the results are never uploaded, stored or logged, and nothing is sent to s4m or any third party. That is important for find-and-replace specifically, because the content is often sensitive: server logs, configuration files, exported records or drafts you would rather not hand to an online service. Everything stays on your device and is discarded when you close the tab. If you build tools of your own and want the same operations at scale, our developer API is the place to look; for quick, private edits, this stays in your browser where it belongs.

人们通过搜索找到此页面

此页面回答的真实搜索短语 — 链接的短语打开详细覆盖它们的页面。