We can replace a portion of a string in multiple ways. Below the popular ones are mentioned and described with the example.
The first parameter is used for searching a string in the whole string and the new string will replace the searched string. This function returns a new string but the original string remains the same.
The original string is GeeksForGeeks The replaced string is GeeksandGeeks
Example 2: Here we use method chaining to use both the methods together at a time.
The replaced string is GeeksandGeeks The original string is GeeksForGeeks
Please Login to comment...