System.out.println("du hast mich".replaceAll("(?<=^(.*)) ", ", $1 "));
// prints "du, du hast, du hast mich"
what is the mean of ^ symbol after the look behind ? (I know standard mean of this symbol is start of the line) and why dot symbol matches up to du then du hast then du hast mich.In briesf why the dot symbol didn't match the whole string?
Please give me an explanation how this regex works properly.I am wondering.Thanks for your interest.
^can mean "beginning of the line" or "not (expression)" (but here, it is the beginning of the line)