For the given sentence as input, censor a specific word with asterisks ‘
Input : word = “computer”
text = “GeeksforGeeks is a computer science portal for geeks. People who love computer and computer codes can contribute their valuables/ideas on computer codes/structures on here.”
Output : GeeksforGeeks is a ******** science portal for geeks. People who love ******** and ******** codes can contribute their valuables/ideas on ******** codes/structures on here.
The idea is to first split given sentence into different words. Then traverse the word list. For every word in the word list, check if it matches with given word. If yes, then replace the word with stars in the list. Finally merge the words of list and print.
GeeksforGeeks is a ******** science portal for geeks. I am pursuing my major in ******** science.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- C program to find and replace a word in a File by another given word
- C program to Replace a word in a text by another given word
- Program for length of the longest word in a sentence
- Java program to count the characters in each word in a given sentence
- Check if a word is present in a sentence
- Python | Reverse each word in a sentence
- Find the word with most anagrams in a given sentence
- Print longest palindrome word in a sentence
- Sums of ASCII values of each word in a sentence
- Print each word in a sentence with their corresponding average of ASCII values
- Python - Kth word replace in String
- Python | Replace rear word in String
- Python program to read file word by word
- Python program to count words in a sentence
- Java program to swap first and last characters of words in a sentence
- Program to find the Encrypted word
- Python | Program that matches a word containing 'g' followed by one or more e's using regex
- Python program for word guessing game
- Python program to remove Nth occurrence of the given word
- Recursive program to replace all occurrences of pi with 3.14 in a given string
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.