Question
Complete the Java code to replace all occurrences of a specific word (case-insensitive) in a string. public class RegexReplacer { public String replaceWord(String text, String wordToReplace, String replacement) { // Example: text="Hello World", wordToReplace="world", replacement="Java" // Expected: "Hello Java" String regex = "(?i)\\b" + Pattern.quote(wordToReplace) + "\\b"; _________ // Line to complete } }
More IT Operating System Questions
- Inheritance is an OOP principle that establishes an "is-a" relationship between classes. What does this relationship primarily allow?
- What is the output of the following part of python program? x = ("apple", "banana", "cherry") print(x)
- Which of the following is a non-linear data structure?
- What is the primary purpose of cookies on a website?
- The latency of a network is
- Which property defines a Binary Search Tree (BST)?
- A good hash function aims to achieve which of the following characteristics?
- Which of the following programming language can be used to process text data for the requirements in various textual data analysis?
- In a multi-homed network, BGP route flapping causes external instability. Which mechanism MOST effectively prevents repeated advertisement of unstable rout...
- Which of the following best describes validation testing?
Hey! Ask a query
Please enter email id
The email must be a valid email address.
Please enter Mobile Number
Please enter valid Mobile Number
Please enter your Doubt