Top "Replaceall" questions

The replaceAll() method in java (and similarly named methods in other languages) is used to replace all instances of a character in a string with another character.

How to take a scanner object and make it a String

I need help doing the following: receiving input using Scanner class (I got this) taking input from scanner and making …

java string java.util.scanner replaceall
Replace certain string in array of strings

let's say I have this string array in java String[] test = {"hahaha lol", "jeng jeng jeng", "stack overflow"}; but now …

java arrays string replace replaceall
Java replaceAll("\\s+") vs replaceAll("\\\\s+")

What's the difference between replaceAll("\\s+") and replaceAll("\\\\s+")? Usually I use \\s+ but sometimes I see \\\\s+.

java replaceall
Replace all "(" and ")" in a string in Java

How to replace all "(" and ")" in a string with a fullstop, in Java? I tried in the following way: String …

java regex string replaceall
Java regex replaceAll multiline

I have a problem with the replaceAll for a multiline string: String regex = "\\s*/\\*.*\\*/"; String testWorks = " /** this should be replaced **/ …

java regex replaceall
Replace '\n' by ',' in java

I want to take input from user as String and replace the newline character \n with , I tried : String test ="…

java string replace replaceall
Java String ReplaceAll method giving illegal repetition error?

I have a string and when I try to run the replaceAll method, I am getting this strange error: String …

java regex string replaceall
Escape space with backslash in java

I want to replace spaces from path string. I tried below but doesn't seems to be working : String path = "/Users/…

java string replace escaping replaceall
Replace substring (replaceAll) workaround

I'm trying to replace a substring that contains the char "$". I'd be glad to hear why it didnt works that …

java string substring replaceall
What does regex "\\p{Z}" mean?

I am working with some code in java that has an statement like String tempAttribute = ((String) attributes.get(i)).replaceAll("\\…

java regex replaceall