View Full Version : Regular expression in java in String class

Mar 22, 2009, 01:21 AM
Hello everyone,

I'm in a middle of confusion now. I'm trying to use the String java class to replace all occurences of word in sub to word in put. The problem is, this doesn't work:

String sub = "Hello";
String put = "Hi";

line.replaceAll(sub, put);

I've been searching through google and other stuff, but I still couldn't understand what went wrong, please help!

Mar 22, 2009, 05:35 AM

replaceAll returns a new string with the results of the replacement.

b e n