Wednesday, November 13, 2013

how to replace all characters in a java string

String line = "Pritom K Mondal";
line = line.replaceAll("(?s).", "X");

Will output:
XXXXXXXXXXXXXXX
 
The (?s) doesn't match anything but sets the DOTALL flag.

No comments:

Post a Comment