Regular expression in java in String class

Discussion in 'Mac Programming' started by Nobita, Mar 21, 2009.

  1. Nobita macrumors 6502

    Oct 5, 2008
    La la land
    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!
  2. lazydog macrumors 6502a

    Sep 3, 2005
    Cramlington, UK

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

    b e n

Share This Page