To replace all words with another String using Java Regular Expressions, we need to use the replaceAll() method . The replaceAll() method returns a String replacing all the character sequence matching the regular expression and String after replacement.