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?
Anagram Solver is a tool used to help players rearrange letters to generate all the possible words from them. You input the letters, and Anagram Maker gives you the edge to win Scrabble, Words With Friends, or any other word game. No matter the length or difficulty of the word, Anagram Solver provides all available word options.
Anagrams — Definition and Examples
Have you ever heard of an anagram? Maybe you recognize the term, but you’re not exactly sure what it means. On the other hand, you might be an expert at using anagrams and have fun with them when playing various word games and board games.
What is an Anagram?
Anagrams are words or phrases you spell by rearranging the letters of another word or phrase. For instance, fans of the Harry Potter series know that Lord Voldemort’s full name is actually an anagram of his birth name, and some people even play games challenging one another to make anagrams still relevant to the original term. For example, «schoolmaster» can be turned into «the classroom», «punishments» becomes «nine thumps», and «debit card» turns into «bad credit».
The only rule is that all the letters from the original word or phrase must be used when they’re reordered to say something entirely different.
History of Anagrams
Historians suggest that anagrams actually originated in the 4th century BC, but weren’t commonly used until the 13th century AD when they were sometimes thought of as mystical. Imagine that!
20 Cool Anagram Examples
Whatever your level of knowledge, Word Finder can be a great tool to assist you to unscramble letters and identify anagrams when playing online and offline games. Here are some examples to help you become more familiar with anagrams ─ starting with the word “anagram” itself.
- anagram = nag a ram
- below = elbow
- study = dusty
- night = thing
- act = cat
- dessert = stressed
- bad credit = debit card
- gainly = laying
- conversation = voice rants on
- eleven plus two = twelve plus one
- they see = the eyes
- funeral = real fun
- meteor = remote
- the classroom = schoolmaster
- meal for one = for me alone
- sweep the floor = too few helpers
- older and wiser = I learned words
- video game = give a demo
- coins kept = in pockets
- young lady = an old guy
Anagram Solver for Scrabble, Words with Friends and Crosswords
How does anagramming help with word games? Easily, it forces you to start reimagining your tiles in a less confusing way. You’ll start looking at how to make any phrase or word instead of simply struggling with what appears on the board and the rack.
Some people are naturals at coming up with anagrams. However, it’s a rare person who can look at language and expertly rearrange the consonants and vowels to arrive at interesting or entertaining new compositions.
What is an Anagram Solver?
An anagram solver is a terrific tool that many people like to rely on to create different letter combinations.
How to Use an Anagram Solver in 3 Simple Steps
- Step #1: Recognize prefixes and suffixes.
Following are common ones:
Some prefixes that start words ─ ab, ad, dis, de, ex, re, sub, un
Some suffixes that end words ─ ed, er, ing, ism, ly, ment, ness, tion
- Step #2: Pick them out.
- Step #3: Reorder the letters into new words.
Anagramming Example
One example is that the word “painter” could become “repaint” by moving the suffix to the beginning so that it becomes a prefix. Alternatively, the letters could be rearranged to make the word “pertain”.
Using Anagram Maker
Now, you may not see how anagramming can really help you win at games such as Scrabble or Words with Friends. However, just think about it for a moment. If you have the board in front of you, and it is loaded with an array of pre-existing words and open spaces, your strategy demands you consider the most lucrative moves. It is not just about making the longest word, but more about the words that give the most points. Anagram generators, like ours, give you solutions with anything from two to six or more letters. You can then use them to plug into the available spaces, finding the highest points possible.
Scrabble Anagram Maker
Seasoned Scrabble players will already know the value of using an anagram generator. After pulling seven tiles from the Scrabble bag and laying them out on their rack, the first player must use a sufficient number to make a complete word to get the game going. There can be a lot riding on this initial play. So, it’s not an uncommon practice for participants to take a little time moving the letters around to see what arrangement will give them the highest score. After all, if they can keep their early advantage, they may eventually win the game!
What’s more, as the game progresses, players will sometimes become stumped about how to display the tiles that they have on the board to gain the most points for the play. In short, having an anagram creator can assist Scrabble players to use their tile points to make words with the best possible score quickly so that the game remains exciting.
Words with Friends Anagram Finder
Similarly, an anagram word finder can be an invaluable device when enjoying Words with Friends. Faced with a jumble of letters, some players may be tempted to cheat or may try out words that they’re not very sure of. Would you believe that the English language has over 171,400 words? In addition, new words are added all the time. Therefore, it’s no wonder that game participants will sometimes become confused or perplexed when they’re attempting to solve multiple words and figure out where to make their next move.
Since Words with Friends is a digital game, you may be engaging with people anywhere in the world unless, of course, you choose to play solo. The game has the potential to be quite fast-paced, and you certainly don’t want to contemplate over your next move to slow things down ─ particularly when you may just be getting to know your opponent! This is where having a word anagram aid to use can be indispensable.
2 Tips to Solve Anagrams for Word Games Players
Are you ready for some final tips about solving anagrams? We’re sure that you can put the following information to good use!
Tip 1: Word Unscrambler
By employing Word Unscrambler, participants in word games are able to search for anagrams by entering the letters and wildcards that they have. Not only that, but they can use an advanced filter to discover words that start or end with particular letters and for other inquiries.
Here are a few examples:
The word “listen” is made up of letters EILNTS. When the word itself if entered in the Word Unscrambler, it quickly finds “silent”.
Along the same lines, “save”, comprised of AESV, reveals the word “vase” in the Word Unscrambler.
Tip 2: Phrase Unscrambler
When we study a phrase on its own, we can become quite stuck on its meaning and it can be difficult to see just how the words and letters can make something new. Hence, Phrase Unscrambler can be very valuable when players are looking to change the letters around in phrases to pinpoint anagrams.
Take a look at these examples:
“Dirty room” contains the following letters ─ DIMOORRTY. Putting the phrase into the Phrase Unscrambler uncovers the word “dormitory”.
By entering the phrase “moon starer” that has these letters ─ AEMNOORRST, the Phrase Unscrambler locates the word “Astronomer”.
Start playing with our anagram finder and discover the surprising number of options just a single collection of tiles can yield. Become an anagram creator today!
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
Enter Letters and word bank below to use the word search solver
Please Wait!!. We are solving your word search puzzle…
Stuck on a word search? Have you spent what feels like hours hunting for that one missing word to solve your puzzle? You’re in the right place: welcome to our Word Search Solver! Whether you need help solving a school assignment or just want to finish your puzzle before you lose your sanity, you can use our tool to quickly and easily find the missing words you’re looking for.
How To Use the Word Search Solver
- Create your board: In the ‘Create Board’ box, type all the letters that appear on your board in the order they appear. Don’t forget to hit return between lines to ensure correct formatting. The board preview will automatically update as you type, so you can check to make sure the board is accurate as you go.
- Enter words to find: If you’re looking for particular words in your search, you can enter them into the ‘Find these words’ box. When searching for multiple words, make sure to separate them using commas. Spaces aren’t necessary between words.
- Set searching parameters: Our tool allows you to search only for specific words or to search for any word found in the dictionary. If you don’t have specific words you want to search for, set the parameter to ‘Dictionary only.’ Even if you are looking for specific words, it can be fun to see all the words that appear in your search, whether intentionally included or not!
Tips for Solving Word Searches
This section describes some tips on how to improve at word search puzzles.
Scan each row for key letters.
Although this is not the quickest way to solve a puzzle, it is likely the most thorough when you are stuck. Instead of randomly searching the board, start at the top left corner of the board and, row-by-row, scan for key letters or letter combinations. For instance, if one of the words you are searching for is ‘puzzle’, scan the board for the letter ‘P’ or ‘Z’. This methodical approach can help ensure you don’t miss anything hiding in plain sight!
Look for the longest words first.
If your board includes long words, try searching for those first. They’re often easy to find, because they take up a significant amount of space on the board — and they can help you narrow down available search areas for other, shorter words.
Make sure you know your board’s rules.
Depending on the word search, there might be different rules about how words can appear on the board. For instance, some word searches might allow for words to be placed diagonally and backwards across the board, while others may not. Make sure you know your board’s rules, so you’re not missing out on different ways the word could appear.
Look for key two-letter combinations.
Sometimes, if a word contains a lot of common letters, that word can be harder to find on the board. To narrow down your search, try to find a unique two-letter combination within the word that you can search for. These combinations will be less likely to appear randomly on your board, and can significantly narrow down your search time. For instance, if you’re searching for the word ‘Aubergine,’ you might look for the ‘AU’ letter combination instead of only searching for ‘A’s.
Scan the board backwards, or turn it upside down.
If you find yourself stumped, a good way to change your perspective is to scan the board backwards or upside down. For instance, starting at the bottom right corner and looking for key letters might help you find something you missed when scanning from left to right. Similarly, physically turning the board upside down might help you notice patterns on the board that you previously missed.
Use your finger or a pen to keep your place.
It can be easy to lose yourself in all those letters. When you’re scanning the board, keep your place with your finger or a pointing device in order to ensure you don’t inadvertently skip any lines or letters.
Where to Find Word Searches of All Difficulty Levels
The Word Finder has our own word search puzzles to browse and play. Whether you’re a teacher looking for a way to entertain their students, or a hobbyist who just likes to keep their mind sharp, we have word searches for all different ages, topics, and difficulty levels. For many of our puzzles, you can even customize the difficulty level for different players. For instance, you can generate an ‘easy’ Taylor Swift word search for one child, and a ‘hard’ Taylor Swift word search for another, so they can work on the similar tasks customized to their abilities. If you’re looking for more of a challenge, we also have a unique ‘brutal’ setting for our word searches, which creates puzzles even the most skilled searcher would struggle to solve. We also have a tool that will allow you to make your own custom word search puzzle. These can be great for gifts, parties, or even the classroom. Word search puzzles have been around for a long time, and it’s fun to be able to create your own!
Feedback for Word Search Solver
What do you think about our Word Search Solver? Was this tool useful for you, or are there features you’d like to add? We’d love to hear from you! Reach out using the ‘Contact Us’ page linked below to share your suggestions. Also be sure to check out our new wordle solver for the popular new word game!
I will be using all user searches which is above 500 thousand now — to use as a guide on how to improve You Go Words. Every word search, regardless if is an error or success — provides me an idea of what should be included if it’s not already available, and I will be working to ensure every word find will be implemented for use. Please be patient with me as I am a single fello working on You Go Words. Thank you for being a user. You can currently find all words lists and answers for any word such as the definition, synonym, antonym, anagram or spelling, derivative, hyponym and hypernym, pertainym and much more. Using the quantum word finder search bar above, you can filter words by the type of speech. The type of speech filters available include articles, singular or plural nouns, pronouns, adjectives, singular or plural verbs, adverbs, conjunctions, prepositions, and interjections.
Word lists by grade level from kindergarden to SAT words, the origin or roots of the word, syllables, length, consonants, vowels, letters and by unique sets of letters. Because English can have more than one type of speech (noun, verb, etc.), I provide you the types of speech I was able to find for each English word. Please use the «add/edit» word feature if you find errors.
How To Use The Word Finder
When you use the quantum virtual word search at the top of this page, you can filter your words in thousands of ways. Use the following cheat sheet to get an idea of the how you can use the finder to craft your search and to get the exact lists of words you desire!
The following searches can be done seperately as individual searches, or, as a combination together to make a super filter word find. You can type using the quantum search box at the top of this page, wich is found throughout every page of this website. Type whatever it is you are searching for, exactly as you want to type it. If you want to find words starting with a-z and have two consonants or 4 vowels — you can say just that ( Words starting with a, have two consonants and four vowels ). Give that search a try. Here are the word find filters you can include in your word search.
Main Style Of User Queries
- Length queries are in the format of : 5 letter words, words with 3 letters, 3 letter
- Solving puzzles is as simple as entering JUST the characters you need such as: blariueiuskjd and using underscore for missing letters such as : wo__s
- Although not recommended, you can search with spaces : w o r d s
- To find words by the first, second, third or up to the eight letter of a word. You can type «words with the 8th letter s, or words with the eighth letter s
- Finding words «without» consonants or vowels, requires you to say that. «Words without consonants». You can also find «words with all vowels», «words with no vowels» and «words with the vowels aie»
- Search by saying «double» consonants/vowels and you’ll find words with double vowels, or double consonants. By saying triple, quadrupal, etc. — you’re then saying «words with three vowels in a row, or four consonants in a row» but it won’t provide a list of words that do not exist such as words with three of the same vowels/consonants in a row — which is why saying «triple,quadrupal,etc.» is not the same as saying «double». Double means two o’s or two r’s, etc.
Word Filter Finding
- Grade Level: kindergarten, or grade 1-12 or SAT words.
- Speech type: Article, Nouns, pronoun, verb, adjective, satellite adjectives, preposition, conjunction, interjections, etc.
- Singular/Plural: find words that are singular or plural by adding that to your search. » singular words «, «plural words»
- Compound Words: simply add the phrase compound words, or that are compound or similar addition to your search
- Origin: if you’re searching for words of a specific root language, or origin. What is the origin? Example: scottish origins
- Language: For names only, you can include language in your search and include origin as well. Example: girl names with scottish roots that are korean language
- Starts With letter: starts with d, starting with a, etc.
- Ends with letter: ends with d, ending with d, etc.
- Spelled like, or containing: A unique tool. Find all words spelling like or containing a set of characters. Example: «spelled with out», or «containing out» will give you words that have the spelling of «out», such as about, youth, without, shout
- Length: how long of a word? five letter words, words with 6 letters.
- Consonants: single or double consonants, such as mississippi with two s’s and two p’s. Search for words with 1-9 consonants. Simple search for double consonant words. To find words with any two consonants in a row, simply search for «# consonants in a row«.
- Vowels: The same search as consonants, such as double vowel words and two vowels in a row like gail, blue, going, etc.
- Syllables: Words with two syllables, three syllables, single syllable words, etc.
- Letters: A unique tool to the web, exclusive to You Go Words (for now). Search «words with the letters ace or even find words that do not have the letters ace. You can not at this time combine both contain and not containing filters.
- Only the letters: You can find words with only the letters/characters you want, such as words with only the letters elvn. Which would give you, «eleven».
- Anagrams: Find anagrams which are words that can be made from another word. This includes repeating characters where as only the letters search does not.
- Unscramble? If you’re just unscrambling a set of letters, enter just that set of letters such as soanntncoo . But if you need to add length, make sure you use «unscramble» in your search. Like: unscramble soanntncoo , 6 letter words
Combining Your Word Search
In the following search style, you can use any of the options mentioned above to filter your word lists. You can combine them (one of each) to have a drilled down word list of words. You can not combine the same filter such as two a’s and two c’s. But, here are some examples of advanced word finds you could search to list results.
Example Search
- Words that are nouns (noun, pronoun, verbs, adjectives, etc.)
Learn more about parts of speech: UTexas.edu Speech.htm
- Words that end with a vowel or words that start with a vowel
- Words that end with a consonant or words that start with a cosnonant
- Words for grade 1 students (kindergarten, grade 1-12, SAT words)
- Words with Old English roots (root(s) or origin(s))
- 10 letter words
- words starting with a
- end in b | ending with the letters ing
- 7 consonants
- single vowel words
- single syllable words
- words with 3 syllables
- Words with the letters ace
- Words with only the letters ace
- words with 4 vowels
- words that do not have the letters ae
- list of words that do not have four vowels
- etc.
Advanced Word List Combinations
Slightly more difficult searches, but you can perform them. The way you type, is up to you. You can even type in words, such as one, two, three and four.
- nouns for grade 1 students that start with a and have two vowels
- Words with seven letters starting with a
- 5 letter words with double vowels starting with a and 2 consonants
Example:- Agree
- 5 letter words with 3 consonants
- triple consonant words
- words with 4 consonants and 4 vowels
- Words with 5 consonants and the letters rst
- 9 letter words with 4 consonants and 2 syllables that do not have the letter a
- 7 letter words with double consonants and 2 vowels, with 1 syllable
- Find a word that ends with out and starts with a
Counting English Words With Filters
Sometimes we want to find out «how many» words contain certain filters, without the rest of the data. You can simply search «how many words» or «how many» to do this filtering. You could say, «count 9 letter words» and get the same answer as «how many words have 9 letters».
- How many words have 9 letters, 7 consonants and 3 syllables?
Fast and sharp word finder for fun and education
Crossword ModeFinds words containing given letters («w??d» — «word», «wood»). Enter a pattern. Use a question mark (?) or a dot (.) for unknown letters. |
Tap here for Xworder Mobile. xworder.com/m
Xworder provides word search tools designed to help you solve and compose crosswords Xworder features: Find words if you know some of the letters that it contains («w??d» — «word», «wood»).
Find words that can be built from the given set of letters («scrabble» — «laser»,
Find words and word combinations by rearranging all letters from the given set («anagram»
A fun game of building word chains by changing one letter at a time («break — bread
Switching between the Full and Limited word lists makes it easier to find what you |
© 2009 — 2011 Xworder.
How to use Xworder
Scrabble® is a registered trademark of Hasbro, Inc. in the USA and Canada.
Outside of the USA and Canada, the Scrabble® trademark is owned by Mattel, Inc.
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
Back to Top
A white circle with a black border surrounding a chevron pointing up. It indicates ‘click here to go back to the top of the page.’
Back to Top
Home
Chevron icon
It indicates an expandable section or menu, or sometimes previous / next navigation options.
Tech
Ye Naiquan /EyeEm/Getty Images
- Find and Replace in Word is a tool that searches a document for a specific word or phrase.
- You can use the tool to replace a word or phrase with another.
- You can review each instance of a word before replacing it, or replace all instances at once.
Find and Replace is a helpful tool in Microsoft Word that searches your document for a specific word or phrase.
You can use the tool to replace one word with another, which can be helpful in situations where you need to go back to change the spelling of a word or check a document for instances of a repeated word to avoid redundancy. For example, if you’re deep into writing a paper and realize you’ve been misspelling someone’s name (let’s say Mark when it should have been Marc), you can use Find and Replace to easily find all instances of Mark and replace it with Marc with a few clicks.
Below, we’ve outlined how to use Find and Replace in Word on macOS and Windows.
Marissa Perino is a former editorial intern covering executive lifestyle. She previously worked at Cold Lips in London and Creative Nonfiction in Pittsburgh. She studied journalism and communications at the University of Pittsburgh, along with creative writing. Find her on Twitter: @mlperino.
Read more
Read less
Abigail Abesamis Demarest is a contributing writer for Insider based in New York. She loves a good glazed donut and nerdy deep dives into the science of food and how it’s made.
Read more
Read less
Related articles
Microsoft Word
Word
More…
Close icon
Two crossed lines that form an ‘X’. It indicates a way to close an interaction, or dismiss a notification.