Replace any character word

‎This tutorial shows three ways to find and replace special characters in Microsoft Word:

1. Enter special characters directly into the Find and Replace dialog box

2. Select special characters from within the Find and Replace dialog box

3. Use keyboard shortcuts or caret codes

We’ll focus on the preset special characters available through Word’s Symbol dialog box.

This tutorial is also available as a YouTube video showing all the steps in real time.

Watch more than 200 other writing-related software tutorials on my YouTube channel.

Please note that Word’s Find and Replace tool doesn’t work with ten of the special characters related to formatting: 1/4 em space, no-width optional break, no-width nonbreak, left-to-right mark, right-to-left mark, left-to-right embedding, right-to-left embedding, left-to-right override, right-to-left override, and pop directional formatting.

For more information on special characters, visit “What Are Special Characters in Microsoft Word?” and “How to Insert Special Characters in Microsoft Word.”

The images below are from Word for Microsoft 365. The steps are the same for Word 2019 and Word 2016 and similar for Word 2013 and Word 2010.

Enter Special Characters Directly into the Find and Replace Dialog Box‎‏

Twelve special characters can be inserted directly into the Find and Replace dialog box by selecting the character:

  • Em dash
  • En dash
  • Em space
  • En space
  • Copyright symbol
  • Registered symbol
  • Trademark
  • Section symbol
  • Paragraph symbol
  • Ellipsis
  • Double opening quote
  • Double closing quote

To insert special characters directly into the Find and Replace dialog box:

1. Select the special character in your text. (The copyright symbol appears in this example.)

Copyright symbol selected.

Figure 1. Copyright symbol selected

2. Select the Home tab in the ribbon.

Home tab in Word 2019/Word 365

Figure 2. Home tab

3. Select Replace in the Editing group.

Replace button in the Editing Group in Word 2019/Word 365

Figure 3. Replace in the Editing group

4. Ensure that the special character appears in the Find what text box in the Find and Replace dialog box. (Some special characters aren’t visible in the text box, so do a test run before selecting the Replace All button in step 6.)

Copyright symbol in the Find What text box in the Find and Replace dialog box

Figure 4. Copyright symbol in the Find What text box

5. Enter the replacement character in the Replace with text box. (The trademark appears in this example.)

Trademark in the Replace With text box in the Find and Replace dialog box in Word 2019 / Word 365

Figure 5. Trademark in the Replace With text box

6. Select the Replace, Replace All, or Find Next button.

  • Replace replaces the next occurrence.
  • Replace All replaces all occurrences.
  • Find Next finds the next occurrence without making a replacement.

Replace, Replace All, and Find Next buttons in the Find and Replace dialog box in Word 2019/Word 365

Figure 6. Replace, Replace All, and Find Next buttons

If you selected Replace All, a series of small dialog boxes will tell you how many replacements were made. Select the Yes and OK buttons to close those dialog boxes.

7. Select the Close button to close the Find and Replace dialog box.

Close button in the Find and Replace dialog box in Word 2019/Word 365

Figure 7. Close button

Pro Tip: You can also copy (ctrl + c) and paste (ctrl + v) the twelve special characters mentioned above directly into the Find and Replace dialog box.

Select Special Characters from within the Find and Replace Dialog Box

Seven special characters can be inserted into the Find and Replace dialog box through the Special drop-down menu:

  • Em dash
  • En dash
  • Nonbreaking hyphen
  • Optional hyphen
  • Nonbreaking space
  • Section symbol
  • Paragraph symbol

To select special characters from within the Find and Replace dialog box:

1. Select the Home tab in the ribbon (see figure 2).

2. Select Replace in the Editing group (see figure 3).

3. Place your cursor in the Find what text box in the Find and Replace dialog box.

Cursor in the Find What text box in the Find and Replace dialog box in Word 2019/Word 365

Figure 8. Cursor in the Find What text box

4. Select the More button. (Skip to Step 5 if the Less button is already visible.)

More button in the Find and Replace dialog box in Word 2019/Word 365

Figure 9. More button

5. Select the Special button.

Special button in the Find and Replace dialog box in Word 2019/Word 365

Figure 10. Special button

6. Select the special character from the menu.

Special menu in the Find and Replace dialog box in Word 2019/Word 365

Figure 11. Special menu

The special character will appear in the Find what text box as a caret code. The caret code for the em dash appears in figure 12, below.

7. Enter the replacement character in the Replace with text box. (Repeat step 5 and step 6 if you are replacing the existing character with one of the seven available in this dialog box. The caret code for the en dash appears in this example.)

Em dash and en dash caret codes in the Find and Replace dialog box in Word 2019/Word 365

Figure 12. Caret codes in the Find What and Replace With text boxes

8. Select the Replace, Replace All, or Find Next button (see figure 6).

9. Select the Close button to close the Find and Replace dialog box (see figure 7).

Use Keyboard Shortcuts or Caret Codes

Fifteen special characters can be inserted into the Find and Replace dialog box using a keyboard shortcut and/or a caret code:

  • Em dash
  • En dash
  • Nonbreaking hyphen
  • Optional hyphen
  • Nonbreaking space
  • Copyright symbol
  • Registered symbol
  • Trademark
  • Section symbol
  • Paragraph symbol
  • Ellipsis
  • Single opening quote
  • Single closing quote
  • Double opening quote
  • Double closing quote

The table below lists the keyboard shortcuts and caret codes for finding and replacing the special characters listed above. Several of these special characters have a keyboard shortcut and a caret code.

Table of Keyboard Shortcuts and Caret Codes for How to Find and Replace Special Characters in Microsoft Word

To insert special characters using keyboard shortcuts or caret codes:

1. Select the Home tab in the ribbon (see figure 2).

2. Select Replace in the Editing group (see figure 3).

3. Type the keyboard shortcut or caret code into the Find what text box (see figure 4).

4. Enter the replacement character in the Replace with text box (see figure 5).

5. Select the Replace, Replace All, or Find Next button (see figure 6).

6. Select the Close button to close the Find and Replace dialog box (see figure 7).

Pro Tip: You can also use the keyboard shortcuts shown above to insert special characters directly into your text. For a full list of keyboard shortcuts for special characters, see “How to Insert Special Characters in Microsoft Word.”

Related Resources

How to Find and Replace Text in Microsoft Word

How to Find and Replace Font Formatting in Microsoft Word

Updated December 09, 2022

Find and replace text

Your browser does not support video. Install Microsoft Silverlight, Adobe Flash Player, or Internet Explorer 9.

  1. Go to Home > Replace.

  2. Enter the word or phrase you want to replace in Find what.

  3. Enter your new text in Replace with.

  4. Choose Replace All to change all occurrences of the word or phrase. Or, select Find Next until you find the one you want to update, and then choose Replace.

  5. To specify only upper or lowercase in your search, select More > Match case. There are several other ways to search in this menu.

Match case

For other options, see Find and replace text

Find and replace basic text

In the upper-right corner of the document, in the search box Enter text to search for in the document, type the word or phrase that you want to find, and Word will highlight all instances of the word or phrase throughout the document.

To replace found text:

  1. Select the magnifying glass, and then select Replace.

    The Replace option is highlighted in the Search box

  2. In the Replace With box, type the replacement text.

  3. Select Replace All or Replace.

    Tips: 

    • You can also open the basic Find and Replace pane with the keyboard shortcut CONTROL + H.

    • When you replace text, it’s a good idea to select Replace instead of Replace All. That way you can review each item before replacing it.

You can find text with special formatting, such as bold or highlight, by using the Format menu.

  1. Select View > Navigation Pane.

    On the View tab, Navigation Pane is checked

  2. In the Navigation Pane, select the magnifying glass.

  3. Select Settings Screenshot of gear, and then select Advanced Find & Replace.

    In the Find and Replace box, Advanced Find and Replace is highlighted

    Notes: 

    • Select the arrow at the bottom of the Find and Replace dialog box to show all options.

    • Shows how to open the Format popup menu

  4. On the Format menu, select the option that you want.

    Shows the Format options

    If a second dialog box opens, select the options that you want, and then select OK.

  5. In the Find and Replace dialog box, select Find Next or Find All.

You can find and replace text with special formatting, such as bold or highlight, by using the Format menu.

  1. Select View > Navigation Pane.

    On the View tab, Navigation Pane is checked

  2. In the Navigation Pane, select the magnifying glass.

  3. Select Settings Screenshot of gear, and then select Advanced Find & Replace.

    In the Find and Replace box, Advanced Find and Replace is highlighted

  4. At the top of the dialog box, select Replace.

    Notes: 

    • Select the arrow at the bottom of the Find and Replace dialog box to show all options.

    • Shows how to open the Format popup menu

  5. On the Find what box, type the text that you want to find.

  6. On the Format menu, select the formatting that you want to find.

    Shows the Format options

    If a second dialog box opens, select the options that you want, and then select OK.

  7. Select in the box next to Replace with.

  8. On the Format menu, select the replacement formatting. If a second dialog box appears, select the formats that you want, and then select OK.

  9. Select Replace, Replace All, or Find Next.

  1. Select View > Navigation Pane.

  2. In the Navigation Pane, select the magnifying glass.

  3. Select Settings Screenshot of gear, and then select Advanced Find & Replace.

    In the Find and Replace box, Advanced Find and Replace is highlighted

    Notes: 

    • Select the arrow at the bottom of the Find and Replace dialog box to show all options.

    • Shows how to open the Format popup menu

  4. On the Special menu, select the special character that you want to find.

    Find special characters

  5. Select Find Next.

  1. Select View > Navigation Pane.

    On the View tab, Navigation Pane is checked

  2. In the Navigation Pane, select the magnifying glass.

  3. Select Settings Screenshot of gear, and then select Advanced Find & Replace.

    In the Find and Replace box, Advanced Find and Replace is highlighted

    Notes: 

    • Select the arrow at the bottom of the Find and Replace dialog box to show all options.

    • Shows how to open the Format popup menu

  4. At the top of the Find and Replace dialog box, select Replace and then select in the Find What box, but don’t type anything there. Later, when you select a special character, Word will automatically put the character code in the box for you.

    Note: Select the arrow at the bottom of the Find and Replace dialog box to show all options.
    Shows how to open the Format popup menu

  5. On the Special menu, select the special character that you want to find.

  6. Select in the Replace with box.

  7. On the Special menu, select the special character that you want to use as a replacement.

  8. Select Replace or Find Next.

  1. Select View > Navigation Pane.

    On the View tab, Navigation Pane is checked

  2. In the Navigation Pane, select the magnifying glass.

  3. Select Settings Screenshot of gear, and then select Advanced Find & Replace.

    In the Find and Replace box, Advanced Find and Replace is highlighted

  4. Select the Use wildcards check box.

    If you don’t see the Use wildcards check box, select Down arrow for more options.

  5. Select the Special menu, select a wildcard character, and then type any additional text in the Find what box.

    Using wildcards in the Find and Replace dialog box

  6. Select Find Next.

    Tips: 

    • To cancel a search in progress, press The Command button.+ PERIOD.

    • You can also enter a wildcard character directly in the Find what box instead of selecting an item from the Special pop-up menu.

    • To search for a character that’s defined as a wildcard character, type a backslash () before the character. For example, type ? to find a question mark.

    • You can use parentheses to group the wildcard characters and text and to indicate the order of evaluation. For example, search for <(pre)*(ed)> to find «presorted» and «prevented.»

    • You can search for an expression and use the n wildcard character to replace the search string with the rearranged expression. For example, type (Newman) (Belinda) in the Find what box and 2 1 in the Replace with box. Word will find «Newman Belinda» and replace it with «Belinda Newman.»

  7. To replace found text:

    1. Select the Replace tab, and then select the Replace with box.

    2. Select Special, select a wildcard character, and then type any additional text in the Replace with box.

    3. Select Replace All, Replace, or Find Next.

      Tip: When you replace text, it’s a good idea to select Replace instead of Replace All. That way you can confirm each replacement to make sure that it’s correct.

You can refine a search by using any of the following wildcard characters.

To find

Use this

For example

Any single character

?

s?t finds «sat» and «set.»

Any string of characters

*

s*d finds «sad» and «started.»

One of the specified characters

[ ]

w[io]n finds «win» and «won.»

Any single character in this range

[-]

[r-t]ight finds «right» and «sight» and «tight.»

Ranges must be in ascending order.

Any single character except the characters inside the brackets

[!]

m[!a]st finds «mist» and «most» but not «mast.»

Any single character except characters in the range inside the brackets

[!x-z]

t[!a-m]ck finds «tock» and «tuck» but not «tack» or «tick.»

Ranges must be in ascending order.

Exactly n occurrences of a character or expression

{ n}

fe{2}d finds «feed» but not «fed.»

At least n occurrences of a character or expression

{ n,}

fe{1,}d finds «fed» and «feed.»

A range of occurrences of a character or expression

{ n, n}

10{1,3} finds «10,» «100,» and «1000.»

One or more occurrences of a character or expression

@

lo@t finds «lot» and «loot.»

The beginning of a word

<

<(inter) finds «interesting» and «intercept» but not «splintered.»

The end of a word

>

(in)> finds «in» and «within,» but not «interesting.»

Word for the web lets you find and replace basic text. You can match case or fine whole words only. For more varied options, open your document in Word for the desktop.

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

Find and Replace Text and Numbers in Word

by Avantix Learning Team | Updated March 7, 2022

Applies to: Microsoft® Word® 2013, 2016, 2019, 2021 or 365 (Windows)

You can find and replace in Word using the Find and Replace dialog box as well as the Navigation Pane. If you use the dialog box, you can find and replace text and numbers and use wildcards for more advanced find and replace tasks. Wildcards are useful when you are not able to find an exact match. You can display the Find and Replace dialog box using a keyboard shortcut or the Home tab in the Ribbon.

Recommended article: How to Quickly Remove Hard Returns in Word Documents

Do you want to learn more about Microsoft Word? Check out our virtual classroom or in-person Word courses >

Note: Screenshots in this article are from Word 365 but are similar in previous versions of Word.

The Replace command appears on the Home tab in the Ribbon in the Editing group:

Replace command on Home tab in the Ribbon to find and replace words or characters.

Using the Find and Replace dialog box to replace words or characters (and match case)

You can perform simple find and replace tasks using the Replace dialog box in its collapsed state. To access more advanced options, you will need to click More in the Replace dialog box to expand it.

To use the Find and Replace dialog box to find and replace text in Word (words or characters) and match case if needed:

  1. Click the Home tab in the Ribbon.
  2. In the Editing group, click Replace to display the Replace dialog box. Alternatively, press Ctrl + H if you prefer to use a keyboard shortcut to open the Replace dialog box.
  3. Enter the text you want to find in the Find What box. You can specify whether Word should locate only matches with the exact capitalization by clicking More and then selecting or checking Match case.
  4. Enter the text you want to replace in the Replace box.
  5. Click Find Next and then click Replace for each occurrence or click Replace All.
  6. Click Close.

In the following example, the Replace dialog box has been expanded to display other options including Match case:

Replace dialog box in Word to find and replace using exanded options.

Finding and replacing using wildcards

To use wildcards, you will need to use the Find and Replace dialog box and expand it to display more options. You can then select the option to Use wildcards. A wildcard can replace one or more characters in a string of text or numbers. The most common wildcard is the asterisk (*).

It’s important to note that wildcard searches are case sensitive. Also, Word uses «lazy» pattern matching so it will stop matching as soon as possible. This means that you could enter part of a word and find that part without using wildcards.

To find and replace text using wildcards in Word:

  1. Position the cursor at the location in the document where you want to start finding and replacing. If you want to start at the beginning of the document, you can press Ctrl + Home.
  2. Click the Home tab in the Ribbon.
  3. In the Editing group, click Replace. Alternatively, press Ctrl + H. A dialog box appears.
  4. Select More to expand the dialog box.
  5. Click in the Find What box.
  6. Select or check the Use wildcards checkbox.
  7. Enter the text and wildcard(s) you want to use. For example, enter s*l to find any text starting with s and ending with l.
  8. Click in the Replace with box.
  9. Enter the text you want to use to replace the text in the Find what box.
  10. Click Find Next to find the first instance of the characters you want to find.
  11. Click Replace or Replace All. If you click Replace, Word will select the next matching characters in the Find what box. If you click Replace All, Word will display a dialog box with the number of replacements. In this case, click OK.
  12. If necessary, click Replace again. Repeat for each instance.
  13. Click Close to close the dialog box.

In the following example, b*s has been entered in the Find what box to find any word starting with starting with b and ending with s:

Find and replace in Word using the Replace dialog box and wildcards.

If you want to undo a Replace or Replace All action, close the dialog box and press Ctrl + Z.

Using common wildcards

The most common wildcards you can use in the Find and Replace dialog box are the asterisk (*) to find multiple characters and the question mark (?) to find a single character.

For example:

b*l will find ball and barrel (a character followed any characters and ending with a specific character)

h?ll will find hill and hall (a character followed by any single character and then followed by 2 characters)

Using wildcards to find one or more instances of the same character

You can also use @ as a wildcard to find one or more instances of the same character.

For example:

catchal@ will find catchal or catchall

Using wildcards for alternate characters and ranges

You can also use wildcards to find alternate characters or ranges of characters. These are entered in square brackets [ ] and may be combined with other wildcards.

[ ] can be used to find each of a set of characters

[ – ] can be used to find each of a set of characters in a range

You can use any character or series of characters in a range within the square brackets (including the space character). Characters are processed in alphanumeric order from lowest to highest.

For example:

[abc] will find any of the letters a, b, or c

[G] will find the upper case letter G

[A-Z] will find any upper case letter

[0-9] will find any single number

[13579] will find any odd number

[0-9A-z] will find any number or letter

f[ai]n will find each of the characters in square brackets such as fan or fin

[b-f]at will find each of a range of characters such as bat, cat, and fat

Using wildcards to omit characters

If you want to omit specific characters, you can use an exclamation mark (!) combined with square brackets.

For example:

[!f]ast will find last and past but not fast

Using wildcards to find the beginning or end of a word

You can use the less than symbol (<) to find the beginning of a word and the greater than symbol (>) to find the end of a word. These wildcards are combined with characters in round brackets or parentheses.

For example,

<(watch) will find watching or watchman

(all)> will find wall or stall

These wildcards can be problematic if you are using a wildcard and you want to find > or < as characters in the document. If this is the case, enter a backslash () in front of the character so that it is not treated as a wildcard.

For example,

<*> will find <h1> or <h2>

Using wildcards to find instances of a character

You can use curly brackets { } to specify the number of instances of a character. These brackets can be combined with a comma to specify the number of instances. Counting can be used with individual characters or with sets of characters.

{n} is used to find the number of instances of a character

{n,} is used to find at least n instances of a character

{n,m} is used to find between n and m instances of a character

For example:

^p{2} will find two consecutive paragraph marks or hard returns (^p is a special character for a paragraph mark in Word)

{3} will find three spaces (there is a space entered before the first curly bracket)

30{2,} will find at least 2 instances of the preceding character such as 3000 or 30000

30{3,4} will find between 3 and 4 instances of the preceding character such as 30000 or 300000 not 300

These last wildcards are particularly useful if you are finding and replacing numbers in Word.

The Find and Replace dialog box offers more functionality as well. For example, you can also Find and Replace Formatting in Word.

Subscribe to get more articles like this one

Did you find this article helpful? If you would like to receive new articles, join our email list.

More resources

How to Add Page Numbers in Word (Step by Step)

How to View Document Statistics in Microsoft Word

How to Update All Figure Numbers in Microsoft Word

How to Check Word Count in Microsoft Word (4 Ways)

How to Superscript or Subscript in Word (with Shortcuts)

Related courses

Microsoft Word: Intermediate / Advanced

Microsoft Word: Designing Dynamic Word Documents Using Fields

Microsoft Word: Long Documents Master Class

Microsoft Word: Accessible Word Documents

Microsoft Excel: Intermediate / Advanced

Microsoft PowerPoint: Intermediate / Advanced

VIEW MORE COURSES >

Our instructor-led courses are delivered in virtual classroom format or at our downtown Toronto location at 18 King Street East, Suite 1400, Toronto, Ontario, Canada (some in-person classroom courses may also be delivered at an alternate downtown Toronto location). Contact us at info@avantixlearning.ca if you’d like to arrange custom instructor-led virtual classroom or onsite training on a date that’s convenient for you.

Copyright 2023 Avantix® Learning

Microsoft, the Microsoft logo, Microsoft Office and related Microsoft applications and logos are registered trademarks of Microsoft Corporation in Canada, US and other countries. All other trademarks are the property of the registered owners.

Avantix Learning |18 King Street East, Suite 1400, Toronto, Ontario, Canada M5C 1C4 | Contact us at info@avantixlearning.ca

word logo

In addition to searching and replacing text, Word lets you search for special characters—tabs, indents, paragraph marks, and so on—and then replace them with other special characters. This can be handy for quick and easy changes which would typically take you a bit more time to do manually.

When Is Searching and Replacing Special Characters Useful?

To understand when searching and replacing special characters may be useful, let’s look at some examples.

  • Let’s say there is a lengthy legal document that you need to edit. You have been asked to replace the word “section” with the section symbol. The section symbol is a pair of overlapping “S” characters and is often used in legal documents to reference a numbered section in a document. Your document is over 50 pages, and there are numerous references to various sections throughout. You can easily replace the word “section” with the section symbol using search and replace.
  • You have just finished writing a draft of your first novel, and it includes a variety of hyphenated words. You need to keep the hyphenated words together by replacing the regular hyphen with a non-breaking hyphen. You start replacing the symbol manually but stop yourself after a few attempts. You know there has to be an easier way. There is! Just use Find and Replace to do the job for you.
  • A colleague has resigned, and you have been assigned the task of editing a report that the colleague worked on before he left. The report is well written, but there is inconsistent paragraph spacing throughout. After clicking Show/Hide, you discover that in some cases, there are two paragraph marks instead of one. One way to correct the paragraph spacing would be to press the Delete key every time you see an extra paragraph mark. But there’s a faster way–just search for every occurrence of two paragraph marks and replace it with one paragraph mark.

There are too many special characters to detail all of them, but let’s take a look at a few general examples of how searching and replacing those characters works.

Example One: Replace Text with a Special Character

Let’s say your document looks something like this:

Word document where the word "section" appears

Note: If you don’t see the special characters in your document, you can turn them on by clicking the Show/Hide button on the Ribbon. Its icon looks like the paragraph symbol.

You need to replace every occurrence of the word “Section” with a section symbol. Switch over to the “Home” tab on Word’s Ribbon and then click “Replace.” Alternatively, you can press Ctrl+H.

Type the word “Section” into the “Find What” box and then click the “More >>” button to expand the Find and Replace options.

Click in the “Replace With” box to put your insertion point there and then click the “Special” button.

Click “Section Character” from the dropdown list.

chose section character from the menu

Notice that the “Replace With” box now contains the text “^%”—this is Word’s code for that section symbol. Click the “Replace All” button. In this example, 16 replacements were made. Click the “OK” button and then close the Find and Replace window.

All occurrences of the word “Section” have now been replaced with the section character.

word document showing section characters

Example Two: Replace a Regular Hyphen with a Non-Breaking Hyphen

For this next example, notice there are quite a few hyphenated words in our sample paragraph, including three occurrences where the hyphenated words are separated on different lines. Let’s replace all the regular hyphens with non-breaking hyphens so that doesn’t happen.

word document showing breaking hyphens

On the “Home” tab, click “Replace” or just press Ctrl+H.

In the “Find What” box, delete any existing text or characters and then type a single hyphen character. Click the “More >>” button if needed to expand the Find and Replace options.

type a single hyphen into the find what box

Click in the “Replace With” box to put your insertion point there. Delete any existing text or characters and then click the “Special” button.

Click “Nonbreaking Hyphen” from the dropdown list.

choose nonbreaking hyphen from the menu

Notice that Word’s code for the nonbreaking hyphen—“^~”— has now been added to the “Replace With” box. Click the “Replace All” button. In this example, 11 replacements were made. Click the “OK” button and then close the Find and Replace window.

Word has replaced all hyphens with nonbreaking hyphens. Notice the hyphenated words on the right margin are no longer separated.

word document showing only non breaking hypens

Example Three: Replacing Two Paragraph Marks with One Paragraph Mark

In this example, we want to replace any double paragraph marks with a single paragraph mark, removing the extra spacing between paragraphs.

word document showing extra paragraph marks between paragraphs

On the “Home” tab, click the “Replace” button. Alternatively, you can press Ctrl+H.

Click in the “Find What” box and then delete any existing text or characters. Click the “More>>” button to open up the additional options, click the “Special” button, and then click the “Paragraph Mark” option from the dropdown list.

choose paragraph mark from the special menu

Notice that Word’s code for a paragraph mark (“^v”) has been inserted into the “Find What” box. Click the “Special” button again and then click “Paragraph Mark” again from the dropdown list to place a second paragraph mark there. (Note that you could also just type “^v^v” into the box yourself if you’re already familiar with the codes.)

choose paragraph mark from the special menu again

There are now two paragraph marks in the Find what box. Click in the “Replace With” box, delete any existing text or characters, and then click the “Special” button. On the dropdown menu, choose “Paragraph Mark.”

For the final step, click the “Replace All” button. In this example, Word made eight replacements. Click the “OK” button and then close the Find and Replace window.

All occurrences of two paragraph marks have been replaced with one paragraph mark.

word document showing extra paragraph marks removed


As you can see, using Find and Replace can save you lots of time when replacing special characters in your documents. And we’ve just scratched the surface here. There are more special characters waiting on that menu for you to explore.

READ NEXT

  • › How to Keep Words on the Same Line in Microsoft Word
  • › HoloLens Now Has Windows 11 and Incredible 3D Ink Features
  • › Liquid Metal vs. Thermal Paste: Is Liquid Metal Better?
  • › How Long Do CDs and DVDs Last?
  • › How to Adjust and Change Discord Fonts
  • › Google Chrome Is Getting Faster
  • › This New Google TV Streaming Device Costs Just $20

I have a string with which i want to replace any character that isn’t a standard character or number such as (a-z or 0-9) with an asterisk. For example, «h^&ell`.,|o w]{+orld» is replaced with «h*ell*o*w*orld». Note that multiple characters such as «^&» get replaced with one asterisk. How would I go about doing this?

nneonneo's user avatar

nneonneo

169k35 gold badges305 silver badges377 bronze badges

asked Oct 20, 2012 at 5:10

tchadwik's user avatar

2

Regex to the rescue!

import re

s = re.sub('[^0-9a-zA-Z]+', '*', s)

Example:

>>> re.sub('[^0-9a-zA-Z]+', '*', 'h^&ell`.,|o w]{+orld')
'h*ell*o*w*orld'

answered Oct 20, 2012 at 5:11

nneonneo's user avatar

nneonneonneonneo

169k35 gold badges305 silver badges377 bronze badges

6

The pythonic way.

print "".join([ c if c.isalnum() else "*" for c in s ])

This doesn’t deal with grouping multiple consecutive non-matching characters though, i.e.

"h^&i => "h**i not "h*i" as in the regex solutions.

crizCraig's user avatar

crizCraig

8,2776 gold badges53 silver badges52 bronze badges

answered Feb 28, 2014 at 13:27

baloan's user avatar

baloanbaloan

6745 silver badges8 bronze badges

Try:

s = filter(str.isalnum, s)

in Python3:

s = ''.join(filter(str.isalnum, s))

Edit:
realized that the OP wants to replace non-chars with ‘*’. My answer does not fit

answered Jan 5, 2015 at 5:15

Don's user avatar

DonDon

16.7k12 gold badges63 silver badges100 bronze badges

0

Use W which is equivalent to [^a-zA-Z0-9_]. Check the documentation, https://docs.python.org/2/library/re.html

import re
s =  'h^&ell`.,|o w]{+orld'
replaced_string = re.sub(r'W+', '*', s)
output: 'h*ell*o*w*orld'

update: This solution will exclude underscore as well. If you want only alphabets and numbers to be excluded, then solution by nneonneo is more appropriate.

Csaba Toth's user avatar

Csaba Toth

9,7465 gold badges75 silver badges119 bronze badges

answered Aug 12, 2016 at 18:54

psun's user avatar

psunpsun

60510 silver badges13 bronze badges

2

Понравилась статья? Поделить с друзьями:
  • Replace all words microsoft word
  • Replace the word in bold in this sentence
  • Replace all words in word with another
  • Replace the word but
  • Replace all words in word document