Illustration of two search boxes, one matching a plain full stop and one treating it as a wildcard

Text & writing

Literal Find and Replace vs. Regular Expressions

Find and replace comes in two flavours. Literal search looks for exactly the characters you type. Regular expressions (regex) treat many of those characters as instructions. Mixing them up is the most common reason a replacement changes far more — or far less — than intended.

Ready to try the tool this guide describes?

What literal matching means

In literal mode, every character stands for itself. Searching for “3.5” finds only “3.5”; searching for “(draft)” finds only that bracketed word. It is predictable, needs no special knowledge, and is what most people expect from a basic find and replace.

Characters that change meaning in regex

So a regex search for “3.5” also matches “305” and “3x5”, and a search for “(draft)” matches the word “draft” with no brackets at all.

Characters that change meaning in regex comparison
CharacterLiteral meaningRegex meaning
.A full stopAny single character
*An asteriskRepeat the previous item any number of times
?A question markThe previous item is optional
[ ]Square bracketsAny one of the characters inside
( )ParenthesesGroup part of the pattern
^ and $Caret and dollar signsStart and end of a line

The replacement-text trap

In regex mode the replacement has codes of its own. In JavaScript and many editors, $& inserts the whole match and $1 inserts the first group; other programs use \1 instead. Typing a price such as “$10” as the replacement in regex mode can therefore produce something unexpected, because the program may read $1 as a reference to a group. Literal replacement inserts dollar signs and backslashes exactly as typed.

When regex is worth it

  • Matching a pattern instead of fixed text: every date, phone number, or order code.
  • Rearranging parts of each match, such as turning “Smith, Jane” into “Jane Smith”.
  • Matching only at the start or end of lines.

For a fixed word or phrase — including prices, file names, and anything with punctuation — literal search is safer and needs no escaping.

Literal vs. Regex Replace FAQ

What is the difference between literal and regex search?
Literal search looks for exactly the characters you type. Regex treats characters such as . * ? ( and [ as pattern instructions.
Why did my search for a full stop match every character?
Regex mode was probably on. In regex, a full stop means “any character”; escape it as \. or switch to plain-text search.
Why did $1 appear strangely in my replacement?
In regex replacements, $1 means “the first captured group”. In literal mode it is inserted as the two characters $ and 1.
Is regex faster than literal search?
Not meaningfully for everyday text. Choose based on whether you need a pattern, not on speed.
Does the Looty Tools Find and Replace support regex?
No. It is deliberately literal, so symbols in both boxes always mean themselves.

Related guides

Open the tool

Jump into Find and Replace Text when you are ready to process your files.

← Back to all guides

More from Looty

Explore Looty’s Ecosystem

Discover more ways Looty can help you learn, organize, create, and make an impact.