
Last checked by the TextEditor.com team
Match case, whole words and regex
A plain search finds the letters wherever they are, also inside longer words. Whole words skips a match when a letter or digit touches it on either side. Match case treats "Cat" and "cat" as different words.
The cat sat on the Cat Mat. A category of cats is a catalog.
| Options | Matches |
|---|---|
| None | 5: cat, Cat, cat, cat, cat |
| Match case | 4: cat, cat, cat, cat |
| Whole words | 2: cat, Cat |
| Match case and whole words | 1: cat |
Regex patterns worth knowing
A regular expression, or regex, is a search pattern. A few signs stand for whole groups of characters, so one pattern can find every number or every email address. Press "Try it" to load a pattern into the tool above.
| Pattern | Finds | Load |
|---|---|---|
| \d+ | Any number, like 7 or 2026 | |
| \s+$ | Spaces at the end of each line | |
| ^\s*$\n | Empty lines | |
| colou?r | "color" and "colour"; the ? makes the u optional | |
| cat|dog | "cat" or "dog" | |
| \b[A-Z]{2,}\b | Words in capitals, like NATO; turn on Match case | |
| [\w.+-]+@[\w-]+\.[\w.]+ | Most email addresses | |
| https?://\S+ | Web links |
To find a sign that has a meaning in regex, put a backslash in front of it: \. finds a period and \( finds a bracket. With Regex off, every sign is found as you type it.
To build and check a pattern first, with every match, its groups and a plain words explanation, use the regex tester.
Swap and reuse parts with $1 and $2
Brackets in a pattern make a group. In the Replace box, $1 puts back what the first group found, $2 the second, and so on. $0 puts back the whole match.
Find (\w+), (\w+) and replace with $2 $1
Ada Lovelace Grace Hopper Alan Turing
Named groups work too: (?<year>\d{4}) in the pattern and $<year> in the replacement.
Several rules in a row: order matters
Press "Add a rule" to run more than one search at once. Rules run from top to bottom, and each rule works on the text the rule above left behind. Turn a rule off with the box on its left.
That is why swapping two words needs a third step. Change "cats" to "dogs" first, and the next rule turns every "dogs" back into "cats", the old ones and the new ones. A placeholder that is not in the text fixes it.
| Rules in order | Result |
|---|---|
| cats → dogs, then dogs → cats | cats chase cats |
| cats → @@, then dogs → cats, then @@ → dogs | dogs chase cats |
Rules you use often can go in a file. Open Rules file and press "Download rules". Next time, press "Open rules file" and pick that file, on this computer or another.
Removing line breaks without losing paragraphs
A paragraph ends with an empty line, which is two line breaks in a row. With "Keep paragraphs" on, Remove line breaks joins the lines inside each paragraph and leaves the empty lines alone. With it off, the whole text becomes one long line. For text from a PDF, with split words and lists, use remove line breaks. It shows each change before you copy.
Roses are red, violets are blue. Sugar is sweet, and so are you.
In place of each break you can put a space, nothing, a comma or your own text. A comma turns a list with one item per line into one line for a spreadsheet or a tag field. "Add line breaks" does the opposite: it breaks long lines at the last space before the length you pick, so a text fits an old email or a terminal. To put the lines of a list in order or drop the repeats, use sort lines.
Line breaks in Word, Excel and code editors
Each program writes a line break in its own way in the Find box. Checked November 2026.
| Program | Line break in Find | Notes |
|---|---|---|
| Microsoft Word | ^p, ^l | ^p is a paragraph mark, ^l a manual line break. Pick them under More, then Special, as Microsoft shows in its Word help page. |
| Excel | Ctrl+J | Press Ctrl+J in the Find what box. The box looks empty, but it holds the line break. |
| Visual Studio Code | \n | Turn on Use Regular Expression (.*). Ctrl+Enter adds a new line in the box. |
| This page | \n | Works with Regex on or off, as long as "\n is a line break" is on. |
Why a pattern can freeze a page
Some patterns take a very long time on some texts. (a+)+$ on a long row of the letter a followed by a b has to try millions of ways to split the row before it gives up. This problem is called ReDoS.
This tool first tests each pattern in a separate background task. If the test takes more than a second, the task is stopped and the tool shows "Pattern too slow", so the page keeps working. Patterns without nested repeats like (a+)+ are almost never slow.
Other ways to fix text
- Clean up pasted texta b → a bThe text cleaner removes extra spaces and hidden characters.
- Put lines in orderc b a → a b cSort lines from A to Z, by number or at random.
- Remove repeated linesa a b → a bKeeps the first copy of each line and drops the rest.
- Change capital lettersaBc → ABCThe case converter makes text upper, lower or title case.