It is as simple as:
"The Shawshank's Redemption".replaceAll("\\S", " _");
We replace all non white-space characters \S
with an underscore followed by a space. This would automatically make what is a space originally, 2 spaces. Note that a trailing space will be produced.
2
solved Java replace with regex [closed]