Regular expressions (regex) look intimidating — they're a dense string of symbols like ^\s+|\s+$. But you don't need to understand all of regex to use it productively. A handful of patterns covers 90% of real-world text cleaning tasks. This guide teaches you the patterns you'll actually use, with plain-English explanations.

What Is Regex and When Should You Use It?

Regex is a language for describing patterns in text. Instead of searching for a fixed string like "hello", you can search for "any line that starts with a number" or "any text between quotation marks." It's supported in Notepad++, VS Code, Google Docs (partially), Excel (not natively, but via REGEXMATCH), Google Sheets, and most code editors.

Use regex when: plain find/replace can't describe the pattern (e.g., "remove all whitespace at the start of each line"), you need to match variable-length content, or you're doing the same transformation repeatedly on different data.

The 8 Patterns You'll Actually Use

^ — matches the start of a line. Find ^ and replace with - to add a bullet to every line.

$ — matches the end of a line. Find ,$ and replace with nothing to remove trailing commas.

\s+ — one or more whitespace characters (spaces, tabs). Find \s+ replace with a single space to normalize spacing.

^\s+ — whitespace at the start of a line. Replace with nothing to remove leading spaces.

\s+$ — whitespace at the end of a line. Replace with nothing to remove trailing spaces.

^\s*$\n — empty lines. Replace with nothing to delete blank lines.

\d+ — one or more digits. Find ^\d+\. to match numbered list items like "1." at the start of lines.

.+ — one or more of any character. Useful inside larger patterns to match variable content.

Practical Example: Clean Up a Pasted List

You paste a numbered list from a PDF and get this: 1. Apple   with a non-breaking space ( ) and trailing whitespace on each line. Two regex operations:

  1. Find ^\d+\.\s* replace with nothing — removes the numbers and dots.
  2. Find \s+$ replace with nothing — removes trailing whitespace.

Result: a clean plain-text list, one item per line, ready to use.

Where to Use Regex Find & Replace

Notepad++: Ctrl+H → check "Regular expression" at the bottom. Full regex support, fast on large files.

VS Code: Ctrl+H → click the .* icon to enable regex mode. Same patterns work.

Google Sheets: REGEXREPLACE(cell, pattern, replacement). For example: =REGEXREPLACE(A1,"\s+"," ") collapses multiple spaces to one.

Online text tools: Some find-and-replace tools support basic regex. Useful for one-off cleanup tasks without opening a code editor.

Try the Free Tool

Find and replace text instantly — supports plain text and basic regex patterns, no signup.

Open Find & Replace →

Frequently Asked Questions

Do I need to know programming to use regex?

No. A small set of patterns covers most text cleaning tasks, and you don't need to understand how regex engines work internally to use them. Learn the 8 patterns in this guide and you'll handle the majority of real-world cases.

Does Excel support regex find and replace?

Not natively in the Find & Replace dialog. Excel does support regex through functions like REGEXMATCH, REGEXEXTRACT, and REGEXREPLACE in Excel 365. For older versions, use Notepad++ or Google Sheets for regex operations.

What does ^ mean in regex?

^ matches the start of a line (in multiline mode, which most text editors use). In a character class like [^abc], it means 'not' — so [^abc] matches any character except a, b, or c. Context determines which meaning applies.

How do I remove all blank lines with regex?

In Notepad++ or VS Code with regex enabled: find ^\s*$\n and replace with nothing. This matches lines that contain only whitespace (or nothing) followed by a newline, and deletes them.

Is there a difference between regex in different tools?

Yes. Most tools support the same core patterns, but advanced features (lookahead, lookbehind, backreferences) vary. For basic text cleaning tasks, the patterns in this guide work consistently across Notepad++, VS Code, and Google Sheets.