Find and replace text
-
Go to Home > Replace.
-
Enter the word or phrase you want to replace in Find what.
-
Enter your new text in Replace with.
-
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.
-
To specify only upper or lowercase in your search, select More > Match case. There are several other ways to search in this menu.
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 , 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:
-
Select the magnifying glass, and then select Replace.
-
In the Replace With box, type the replacement text.
-
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.
-
Select View > Navigation Pane.
-
In the Navigation Pane, select the magnifying glass.
-
Select Settings , and then select Advanced Find & Replace.
Notes:
-
Select the arrow at the bottom of the Find and Replace dialog box to show all options.
-
-
-
On the Format menu, select the option that you want.
If a second dialog box opens, select the options that you want, and then select OK.
-
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.
-
Select View > Navigation Pane.
-
In the Navigation Pane, select the magnifying glass.
-
Select Settings , and then select Advanced Find & Replace.
-
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.
-
-
-
On the Find what box, type the text that you want to find.
-
On the Format menu, select the formatting that you want to find.
If a second dialog box opens, select the options that you want, and then select OK.
-
Select in the box next to Replace with.
-
On the Format menu, select the replacement formatting. If a second dialog box appears, select the formats that you want, and then select OK.
-
Select Replace, Replace All, or Find Next.
-
Select View > Navigation Pane.
-
In the Navigation Pane, select the magnifying glass.
-
Select Settings , and then select Advanced Find & Replace.
Notes:
-
Select the arrow at the bottom of the Find and Replace dialog box to show all options.
-
-
-
On the Special menu, select the special character that you want to find.
-
Select Find Next.
-
Select View > Navigation Pane.
-
In the Navigation Pane, select the magnifying glass.
-
Select Settings , and then select Advanced Find & Replace.
Notes:
-
Select the arrow at the bottom of the Find and Replace dialog box to show all options.
-
-
-
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.
-
On the Special menu, select the special character that you want to find.
-
Select in the Replace with box.
-
On the Special menu, select the special character that you want to use as a replacement.
-
Select Replace or Find Next.
-
Select View > Navigation Pane.
-
In the Navigation Pane, select the magnifying glass.
-
Select Settings , and then select Advanced Find & Replace.
-
Select the Use wildcards check box.
If you don’t see the Use wildcards check box, select .
-
Select the Special menu, select a wildcard character, and then type any additional text in the Find what box.
-
Select Find Next.
Tips:
-
To cancel a search in progress, press + 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.»
-
-
To replace found text:
-
Select the Replace tab, and then select the Replace with box.
-
Select Special, select a wildcard character, and then type any additional text in the Replace with box.
-
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.
You should use a Hamming Distance. For given two words of equal length, it is the number of positions at which the corresponding symbols are different.
Your algorithm could look like this:
-
Organize your words into a graph structure, where two words are connected only when Hamming distance between them equals 1, i.e. : DAMP and LAMP will be connected (h.d. is 1), but DAMP and LIMP — no (h.d. is 2).
-
For given two words, check if there exists a path in your graph between first word and second. If so, write the path. For this you can use any of pathfinind algorithm.
Example
Words : DAMP, LIKE
We are searching our graph and finds that there is a path between those words. Using, for example, Dijkstra’s algorithm we find following path:
Path : DAMP -> LAMP -> LIMP -> LIME -> LIKE
Let’s face it. Sometimes when you’re writing, you find yourself wondering if there’s another word for, well, the word you keep using! Repetitive words tend to creep into our writing when we’re feeling stuck, and they can make an otherwise excellent email or perfect paper seem a little less polished than we’d hoped. At worst, repeating words in your writing can make it down right boring!
When to find another word in your writing
There are plenty of reasons this happens. While the average 20-year-old native English speaker knows an average of 42,000 words, we only use about 20,000 of them. And sometimes repetitive words can actually help make keep your reader engaged — Dr. Martin Luther King Jr. practiced anaphora when he repeated the phrase “I have a dream” in eight consecutive sentences. His speech is stirring and well-remembered because of his careful crafting and repetition.
So how do you know when you should find another word for the words you’re repeating, and where do you find another word to make your writing more clear and engaging? Take a look at these sentences:
I really liked this article I found. I thought you would like this article too.
If the words “like” and “article” jumped out at you because they’re repeated and you wish the writer had found another word for each of them, you’re getting the picture. Do you worry the writer is going to drone on and on, using the same words over and over?
The good news? You can drop the duplicates with a little help! Keep reading for the seven best resources to help you write more clearly.
Grammar Coach™
Hey, we had to start with the best, didn’t we? Even the best writers need a helping hand. That’s where Grammar Coach by Thesaurus.com comes in. Use Grammar Coach™ to check your spelling, find the best words to use, and make sure your writing is as clear as possible.
The new repetitive words feature can even let you know if you’re using the same word too many times, and suggest alternatives to make editing a cinch. It’s like having your own virtual writing mentor.
Don’t hesitate, try Grammar Coach today and discover how easy it is to get the writing boost you’re looking for!
Online style guides
Different types of writing require different style guides — documents that outline rules for writing for different organizations. Many newspapers use them, and they can help you curb some of those repetitive word habits. Luckily, you can find most style guides online. For most types of writing, you’ll want to check out the Associated Press (AP) Stylebook, the Chicago Manual of Style, or any of our easy grammar help articles that explain the differences between these styles.
NaNoWriMo
Breaking the repetitive word habit can be as simple as flexing your writing muscles a little more! Creative writers can find prompts, help, and support through NaNoWriMo. The name is a shortened version of National Novel Writing Month, which takes place in November, but the site provides prompts and message boards for writers all year long.
You can also connect with a writing community through the event and get helpful feedback and team motivation for finishing the writing challenge month out strong.
The Word of the Day
A dictionary is a handy tool for writing of any kind, and Dictionary.com makes it easy to double check your spelling and make sure that word you keep using really means what you think it means. But dropping your habit of repeating the same words could be as simple as building up your vocabulary by learning new words! Good thing you can pick up a fresh one each day with Word of the Day, huh?
Writer’s Digest
Becoming a great writer means learning as much as possible about your craft. Whether you’re interested in fiction writing, nonfiction writing, or poetry, Writer’s Digest has articles from real writers and experts with helpful suggestions for creating a dedicated writing practice and honing your skills.
Daily Writing Tips
Dig into a new writing-related topic each day with articles from Daily Writing Tips. A new piece of writing help is published each day covering topics related to syntax, vocabulary, and hot topics related to the writing industry at large.
The thesaurus
What’s another word for place to find the best word alternatives? We’re a little biased, but we’re going to say it’s Thesaurus.com!
You can look up synonyms and antonyms for thousands of words, get help with your spelling and punctuation, read helpful explainers about the trickiest grammar topics, and even learn brand new synonyms every single day with our free Synonym Of The Day feature.
Exchange one text string for another in any version of Word
Updated on October 29, 2021
What to Know
- Open the Find and Replace tool in Word with the keyboard shortcut CTRL+H.
- Find and Replace doesn’t take capitalization into account unless you specifically tell it to.
- To replace capitalization, select More in the Find and Replace box, then Match Case > Replace or Replace All > OK.
All editions of Microsoft Word offer a feature called Find and Replace. Use this tool to search for a specific word, number, or phrase in a document and replace it with something else. You can also make several replacements at once—like changing a name or fixing something you’ve consistently misspelled. Use it, also, to replace numbers or punctuation and cap or uncap words.
If you turn on Track Changes before you begin, you can reject the replacement or deletion of any unintended word.
Find and Replace a Word
The Microsoft Word Find and Replace dialog box, in its simplest form, prompts you to type the word you’re looking for and the word you want to replace it with. Then, click Replace, and either allow Word to change every entry for you or, go through them one at a time.
To open the tool, press Ctrl+H (Cmd+H on Mac).
Change Capitalization in Microsoft Word
The Find and Replace feature doesn’t take into account anything about capitalization unless you specifically tell it to. To get to that option you’ll need to click the More option in the Find and Replace dialog box:
- Open the Find and Replace dialog box using your favorite method. We prefer Ctrl+H.
- Click More.
- Type the appropriate entry in the Find What and Replace With lines.
- Click Match Case.
- Click Replace and Replace again, or, click Replace All.
- Click OK.
Advanced Options
When you select the More expander in the Search and Replace dialog box, you’ll encounter several customizations. The list of items varies according to which version of Word you’re running.
Search Options
Select the check boxes to include or exclude things like punctuation, white-space characters, or substrings. Plus, apply tools like word-form matching (i.e., walked also matches walking) and Soundex matching (Karin matches Karen).
Replace Options
Word supports more advanced substitutions, too. Use special characters to substitute text markup with symbols. For example, replace a character code like & with an ampersand. This approach is useful for de-cluttering pasted HTML text that uses HTML codes to render certain symbols.
Thanks for letting us know!
Get the Latest Tech News Delivered Every Day
Subscribe
Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article
Pre-requisite: File Handling in C
Given a file containing some text, and two strings wordToBeFind and wordToBeReplacedWith, the task is to find all occurrences of the given word ‘wordToBeFind’ in the file and replace them with the given word ‘wordToBeReplacedWith’.
Examples:
Input : File = "xxforxx xx for xx", wordToBeFind = "xx", wordToBeReplacedWith = "geeks" Output : geeksforgeeks geeks for geeks
Approach: The idea here is to read the contents from the given file, process the find and replace, and then store the output in another file.
- Make objects of FILE (ifp and ofp)
- Open two files, one for file input in read mode and another in write+ mode
- Check for the file to be opened correctly
- Read the contents of the existing input file word by word
- As using fgets takes the input of new line character(i.e. enter key) also we just copy the null character of the string one position back so that the newline is replaced with “”
- We run a loop till the end of file is reached and scan each word in the file and store it in a variable “read”.
- Then we compare “read” with “wordToBeFind” and if the result is true, we use “strcpy()” to replace “read” with “wordToBeReplacedWith”.
- Show the word replacement through printf
- Now again we shift the filepointer at the beginning of the file and print the file contents of the output file.
Below is the implementation of the above approach:
C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void
findAndReplaceInFile()
{
FILE
*ifp, *ofp;
char
word[100], ch, read[100], replace[100];
int
word_len, i, p = 0;
ifp =
fopen
(
"file_search_input.txt"
,
"r"
);
ofp =
fopen
(
"file_replace_output.txt"
,
"w+"
);
if
(ifp == NULL || ofp == NULL) {
printf
(
"Can't open file."
);
exit
(0);
}
puts
(
"THE CONTENTS OF THE FILE ARE SHOWN BELOW :n"
);
while
(1) {
ch =
fgetc
(ifp);
if
(ch == EOF) {
break
;
}
printf
(
"%c"
, ch);
}
puts
(
"nnEnter the word to find:"
);
fgets
(word, 100, stdin);
word[
strlen
(word) - 1] = word[
strlen
(word)];
puts
(
"Enter the word to replace it with :"
);
fgets
(replace, 100, stdin);
replace[
strlen
(replace) - 1] = replace[
strlen
(replace)];
fprintf
(ofp,
"%s - %sn"
, word, replace);
rewind
(ifp);
while
(!
feof
(ifp)) {
fscanf
(ifp,
"%s"
, read);
if
(
strcmp
(read, word) == 0) {
strcpy
(read, replace);
}
fprintf
(ofp,
"%s "
, read);
}
rewind
(ofp);
while
(1) {
ch =
fgetc
(ofp);
if
(ch == EOF) {
break
;
}
printf
(
"%c"
, ch);
}
fclose
(ifp);
fclose
(ofp);
}
void
main()
{
findAndReplaceInFile();
}
How to execute the above code:
- Copy the source code from here and paste it in an offline IDE
- Save the program.
- Create a file named “file_search_input.txt” and save it in the folder where you saved the above-copied program.
- Now open the terminal or offline IDE and run the program
Output:
Time complexity: O(n)
Where n is the number of characters in the file being searched. This is because the time taken for this algorithm is directly proportional to the number of characters in the file.
Space complexity: O(1)
This algorithm does not use any additional data structures and hence the space complexity is constant, O(1).
Like Article
Save Article
How do I use OneLook’s thesaurus / reverse dictionary?
OneLook lets you find any kind of word for any kind of writing.
Like a traditional thesaurus, you
can use it to find synonyms and antonyms, but it’s far more flexible.
Describe what you’re looking for with a single word, a few words,
or even a whole sentence. Type in your description and hit
Enter (or select a word that shows up in the autocomplete preview)
to see the related words.
You can order, filter, and explore the
words that come back in a variety of creative ways.
Here’s a video which
goes over some of the basics.
What are some examples?
Exploring the results
Click on any result to see definitions and usage examples tailored to your search,
as well as links to follow-up searches and additional usage information when available.
OneLook knows about more than 2 million different
words and expressions covering every topic under the sun.
Try exploring a favorite topic for a while and you’ll be surprised
how much new stuff there is to learn!
Ordering the results
Your results will initially appear with the most closely related word shown first,
the second-most closely shown second, and so on.
You can re-order the results in a variety of different ways, including
alphabetically, by length, by popularity, by modernness, by formality, and by other
aspects of style. Click the
box that says «Closest meaning first…» to see them all.
(Here’s a short video about sorting and filtering
with OneLook Thesaurus.)
Filtering the results
You can refine your search by clicking on the «Advanced filters» button
on the results page. This lets you narrow down your results to match
a certain starting letter, number of letters, number of syllables, related
concept, meter, vowel sound, or number of syllables.
Read more details on filters if you’re interested in how they work.
I’m only looking for synonyms! What’s with all of these weird results?
For some kinds of searches only the
first result or the first few results are truly synonyms
or good substitutions for your search word.
We highlight these results in yellow.
Beyond that, the results are meant to inspire you to consider similar words and adjacent
concepts. Not all of the results will make sense at first, but they’re all
connected with your search in some way. We’d rather give you too many options than
too few. If you’re unsure of a word, we urge you to click on
it to check its definitions and usage examples before using it in your Oscars
acceptance speech or honors thesis.
What are letter patterns?
If you know some letters in the word you’re looking for, you can enter a pattern instead of, or in addition to, a description. Here are how
patterns work:
- The asterisk (*) matches any number of letters.
That means that you can use it as a placeholder for any part of a word or phrase.
For example, if you enter blueb* you’ll get all the terms that start with «blueb»; if you enter
*bird
you’ll get all the terms that end with «bird»; if you enter
*lueb*
you’ll get all the terms that contain the sequence «lueb»,
and so forth. An asterisk can match zero letters, too. -
The question mark (?) matches exactly one letter.
That means that you can use it as a placeholder for a single letter
or symbol. The query l?b?n?n,
for example, will find the word «Lebanon». -
The number-sign (#) matches any English consonant.
For example, the query tra#t finds the word «tract» but not «trait». -
The at-sign (@) matches any English vowel (including «y»).
For example, the query abo@t finds the word «about» but not «abort». -
NEW! The comma (,) lets you combine multiple patterns into one.
For example, the query ?????,*y* finds 5-letter words
that contain a «y» somewhere, such as «happy» and «rhyme». -
NEW! Use double-slashes (//) before
a group of letters to unscramble them (that is, find anagrams.)
For example, the query //soulbeat will find «absolute»
and «bales out»,
and re//teeprsn will find «represent» and «repenters».
You can use another double-slash to end the group and put letters you’re sure of to the
right of it. For example, the query //blabrcs//e will find «scrabble».
Question marks can signify unknown letters as usual; for example, //we???
returns 5-letter words that contain a W and an E, such as «water» and «awake». -
NEW! A minus sign (—) followed by some letters at the end of a pattern means «exclude these letters». For example, the query sp???-ei finds 5-letter words that start with «sp» but do not contain an «e»or an «i», such as «spoon» and «spray».
-
NEW! A plus sign (+) followed by some letters at the end of a pattern means «restrict to these letters». For example, the query *+ban finds «banana».
- On OneLook’s main search or directly on OneLook Thesaurus, you can combine patterns and thesaurus lookups
by putting a colon (:) after a pattern and then typing
a description of the word, as in
??lon:synthetic fabric and the other examples above.
Other ways to access this service:
- Drag this link to your browser’s bookmarks bar for a convenient button that goes to the thesaurus:
OneLook
- Enter onelook.com/word into your browser’s address bar to go directly to the OneLook Thesaurus entry for word.
- We offer a OneLook Thesaurus iPhone/iPad app
for a low subscription fee, with a two-week free trial.
This gives you OneLook at your fingertips, and
several cool app-only features, while helping us maintain the service for all! - If you use Google Docs, the thesaurus is integrated into the free OneLook Thesaurus Google Docs Add-On as the «Synonyms» button. (Wildcard patterns are not yet suppoerted by this add-on.)
- If you regularly use the main OneLook site, you can put colon (:) into any OneLook search box,
followed by a description, to go directly to the thesaurus. - If you’re a developer, the Datamuse API gives you access to the core features of this site.
Is this available in any language other than English?
The same interface is now available in Spanish at OneLook Tesauro
as a beta version. More languages are coming!
How does it work?
We use a souped-up version of our own Datamuse API,
which in turn uses several lingustic resources described in the «Data sources» section
on that page. The definitions come from Wiktionary,
Wikipedia, and WordNet.
Here are some known problems
with the current system.
Much gratitude to Gultchin et al for the algorithm behind the «Most funny-sounding» sort order.
Profanity and problematic word associations
If you’re using this site with children, be forewarned you’ll
find profanity and other vulgar expressions if you use OneLook frequently.
(We take an unflinching look at how words have actually been used; scrubbing out
hurtful wordswould be a disservice to everyone.)
Some of the thesaurus results come from a statistical analysis of the
words in a large collection of books written in the past two
centuries. A handful of times we’ve found that this analysis can lead
us to suggest word associations that reflect racist or harmful
stereotypes present in this source material. If you see one of these,
please know that we do not endorse what the word association implies.
In egregious cases we will remove it from the site if you
report it to us via the feedback link below.
Privacy
No personally identifying information is ever collected on this site
or by any add-ons or apps associated with OneLook. OneLook Thesaurus sends
your search query securely to the Datamuse API, which keeps a log file of
the queries made to the service in the last 24 hours. The log file is deleted
after 24 hours and we do not retain any long-term information about your
IP address or invididual queries.
Who’s behind this site and where can I send my comments and complaints feedback?
OneLook is a service of Datamuse.
You can send us feedback here.
The sunburst logo (🔆) is the emoji symbol for «high
brightness», which we aspire to create with OneLook. (The
graphic came from the open-source Twemoji
project.)