How to find and replace string?
The code below demonstrates the use
Matcher.appendTail() methods to create a program to find and replace a sub string within a string.
Another solution that can be used to search and replace a string can be found on the following example: How to create a string search and replace using regex?.
Here is the result of the above code:
Input : Please use your Pen to answer the question, black pen is prefered.
Output: Please use your pencil to answer the question, black pencil is prefered.