Scala String replaceAll() method with example Last Updated : 03 Oct, 2019 Improve Improve Like Article Like Save Share Report The replaceAll() method is used to replace each of the stated sub-string of the string which matches the regular expression with the string we supply in the argument list. Method Definition: String replaceAll(String regex, String replacement) Return Type: It returns the stated string after replacing the stated sub-string with the string we provide. Example #1: // Scala program of replaceAll() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Applying replaceAll method val result = "csoNidhimso".replaceAll(".so", "##") // Displays output println(result) } } Output: ##Nidhi## Example #2: // Scala program of replaceAll() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Applying replaceAll method val result = "csoNidhimsoSingh ".replaceAll(".so", "##") // Displays output println(result) } } Output: ##Nidhi##Singh Like Article Suggest improvement Previous Scala String toLowerCase() method with example Next Scala String replaceFirst() method with example Share your thoughts in the comments Add Your Comment Please Login to comment...