Special and wildcard characters for searching and replacing in MS Word

Microsoft Word provides an extremely powerful search and replace tool. Using it correctly will allow you to simplify and speed up document editing.

What's that for?

Example 1

A simple example of search and replace.

It is necessary to replace the surname Bradley in the document with the surname Bradford.

Find Replace Search and replace result
Jackson Jefferson Jackson will be replaced by Jefferson

It is possible to make one such substitution to make an immediate change in the document:

Jackson to Jefferson,
Jacksons to Addisons,
Jackson's to Davidson's,
etc.?

Yes, it's possible. To do this, use special characters.

Example 2

The document contains many decimal fractions. One part contains dots, the other part contains commas.

Is it possible to make such a substitution to make the writing uniform?

Yes, it's possible. To do this, use special characters.

What are special characters?

There are two types of special characters in Microsoft Word – special characters and wildcards. Both can be entered in the search and replace box using the "Special" button ("Special") in the "Find and Replace" dialog box.

Special characters are characters that are never on the keyboard and/or that cannot be entered directly into the search or replace field. For example: paragraph end character, optional split, fixed space, etc.

Find and replace

If the Use wildcards option is enabled in the search and replace dialog, it is possible to create complex search conditions. Wildcards are used for this purpose. You can use them to specify ranges of characters and expressions that satisfy a number of conditions.

Some symbols and characters can be used only in the search field, others – in the replacement field. The ability to use others depends on whether the Use wildcards option is enabled.

Use wildcards

"Find" field

Special characters that can only be used if Use wildcards is never enabled.

Special characters What they mean
^p Paragraph mark (¶)
^? Any character
^# Any digit
^$ Any letter
^e Endnote mark
^d Field
^f Footnote mark
^b Section break
^w Whitespace (space, tab, etc.)

Special characters whose use is independent of the Use wildcards option.

Special characters What they mean
^t Tab character (➞)
^a Comment mark
^0nnn ANSI or ASCII characters
^^ Caret character^
^g Graphic
^n Column break
(···Column Break···)
^l Manual line break (↵)
^m Manual page break
(---Page Break---)
^+ Em dash (—). Symbol with code 0151.
^= En dash (–). Symbol with code 0150.
^s Nonbreaking space (°)
^~ Nonbreaking hypen (-)
^- Optional hypen (¬)

Wildcards that can only be used if the Use wildcards option is enabled.

Special characters What they mean Example find What it finds
? Any one character h?t hat, het, hit, h5t, h¶t etc.
* Any number of any characters h*t heart, Headhunter, hurdle.¶height etc.
[] Square brackets. One of the specified characters h[aoi]t hat, hot, hit
[-] Square brackets. Finding an interval. The interval must be specified in ascending character code order. [a-z] Finds any lowercase letter
[A-Z] Finds any uppercase letter
[0-9] Finds any digit
[!] Any single character that is never followed by an exclamation mark h[!a]t hot, hit, etc., never hat
[!t-z] Any character that is never in the interval specified after the exclamation point [!t-z]ok Bok, Lok, etc., never bok, lok
[!0-9] Any character except numbers
{n} Composite brackets. Exact number of occurrences of the preceding character or expression. An expression is anything that is enclosed in parentheses. An expression can contain both specific characters and special characters. 10{3} 1000, never 100, 10000
10(20){2} 102020, never 1020, 10202020
{n;} n or more occurrences of the previous character or expression 10{3;} 1000, 10000, 100000 etc., never 100
{n;m} From n to m occurrences of the previous character or expression 10{3;4} 1000, 10000, never 100, 100000
@ Zero or more occurrences of the preceding character or expression 10@ 10, 100, 1000, 10000 etc.
< Beginning of the word <bok bokeh, never bosbok
> The end of the word bok> bosbok, never bokeh

Field "Replace"

Special characters whose use is independent of the Use wildcards option.

Special characters What they mean
^p Paragraph mark (¶)
^t Tab character (➞)
^0nnn ANSI or ASCII characters
^^ Caret character
^c Clipboard contents
^& Contents of the Find what box
^n Column break
(···Column Break···)
^l Manual line break (¿)
^m Manual page break (---Page Break---)
^+ Em dash (—)
^= En dash (–)
^s Nonbreaking space (°)
^~ Nonbreaking hypen (-)
^- Optional hypen (¬)

Wildcards that can only be used when Use wildcards is selected.

Wildcards What they mean
\n Expression n

Note:

To search for characters in the document that are used as special characters in the search box, you must prefix them with a backslash (\). If, for example, the "Use wildcards" option is selected, you must enter a backslash (\!) before the exclamation point when searching for it.

Examples

In the search and replace dialog, the Use wildcards option must be selected. This condition must be met for all examples below.

Find Examples

"Find" field What it finds
[!^0013]^0013[!^0013] One end of a paragraph, surrounded by two endings (see details below).
^0013{2;} Two or more paragraph ends
^0032{2;} Two or more spaces
[.,:;\!\?] Punctuation mark ( . , : ; ! ? )
[0-9]^0032[0-9] Two digits separated by a space
[0-9]^0032[A-Za-z] Number and letter separated by a space.
(See below for details).
-[0-9] Hyphen and number
<[0-9]@-[0-9]@> Two whole numbers separated by a hyphen.
\([0-9]\) Number in brackets
<[0-9]@> Integer (more precisely - a continuous sequence of digits)
<[0-9]@,[0-9]@> A decimal fraction, separated by a comma
<[A-Za-z]@> Word
<[А-яЁё]@> Word in Cyrillic
<[А-ЯЁ][а-яё]@> Word in Cyrillic lower case, first letter upper case.
(See below for details).

Detailed analysis of some search strings

[!^0013]^0013[!^0013]

1st character of the "Find" field 2nd character 3rd character
[!^0013] ^0013 [!^0013]
Any character, but not the end of the paragraph End of paragraph Any character, but not the end of the paragraph
The code character 0013 (end of paragraph) is shown in square brackets. The "!" indicates that any character except the end of the paragraph can be in this position. End of paragraph (character code 0013). The code character 0013 (end of paragraph) is shown in square brackets. The "!" indicates that any character except the end of the paragraph can be in this position.

[0-9]^0032[A-Za-zА-яЁё]

1st character of the "Find" field 2nd character 3rd character
[0-9] ^0032 [A-Za-zА-яЁё]
Any digit Space Any letter (Latin or Cyrillic)
The range of characters from 0 to 9, i.e. digits, is given in square brackets. Space (character with code 0032). A valid character is defined by three intervals and two specific characters.
A-Z — Latin capital letters;
а-z — Latin lower case letters;
А-я — Cyrillic upper and lower case letters;
Ёё — capital and small letter ё.

<[А-ЯЁ][а-яё]@>

1st position of the "Find" field 2nd position
<[А-ЯЁ] [а-яё]@>
Any capital Cyrillic letter Any lower case Cyrillic letters
The range of characters from A to Я and Ё (i.e. any Cyrillic capital letter) is given in square brackets.
The "<" indicates that the capital letter should be at the beginning of the word.
The interval in square brackets defines all Cyrillic lowercase letters.
The "@" indicates that the number of Cyrillic lowercase letters can be zero or greater.
The character ">" indicates the end of a word.

Operations with expressions

To work with expressions, check Use wildcards.

In the "Find field, the expression is whatever is enclosed in parentheses (which in this case function as special characters). An expression can contain either specific or wildcard characters or special characters. The order of expressions is determined by their numbering.

In the "Replace" field, expressions are represented as: \n, where n is the expression number in the "Find" field.

A simple example of working with expressions

Edit the sentence: cat chases mouse

"Find" field Field "Replace" Finding and replacing result
(cat )(chases )(mouse) \3\2\1 mouse chases cat
\1 quickly \3\2 cat quickly mouse chases
\1 and dog - best friends - both love a \3 cat and dog – best friends – both love a mouse
\1\2\3 . Dog does not \2\3 cat chases mouse . Dog does not chases mouse

Příklady vyhledávání a nahrazení

"Find" field Field "Replace" Finding and replacing result
([!^0013]^0013)([!^0013]) \1^0013\2 Insert a blank line between those paragraphs that did not have a blank line between them.
(^0013){2;} \1 Delete blank lines
^0032{2;} ^0009 Replace two or more spaces with a tab
^0032([.,:;\!\?]) \1 Deletes the space before the punctuation mark ( . , : ; ! ? )
([0-9])^0032([0-9]) \1^s\2 Replacing the space between numbers with a fixed space
([0-9])^0032([A-Za-zА-яЁё]) \1^s\2 Replace the space between a number and a letter (Latin or Cyrillic) with a fixed space
-([0-9]) ^0150\1 Replacing a dash before a digit with a minus sign
\(([0-9])\) [\1] Replace round brackets around a number with square brackets

Another example

The document contains many decimal fractions. One part contains dots, the other part contains commas.

It is necessary to make such a substitution so that everything is uniform.

Here are two possibilities for such replacement:

"Find" field Field "Replace" Finding and replacing result
(<[0-9]@).([0-9]@>) \1,\2 The decimal point will be replaced by a comma
(<[0-9]@),([0-9]@>) \1.\2 Decimal comma will be replaced with a point