The replace() method is used: The replace method is used to replace a character / string with another character / thread. It takes two parameters, the first is the string to be replaced and the second is the string to be replaced. In this case, the first parameter is the character to be deleted and the second parameter can be given as an empty character unit. This will remove the character from the finish line. This method removes the initial occurrence of the thread.