My friend is trying to finish his Computer Science project but one thing is preventing him from doing that: the String method replaceAll doesn't seem to be working correctly. He wants to remove all the instances of new line or a return (\n or a \r) and replace them with a couple spaces.
for(int c = 0; c<bible.size(); c++){
bible.get(c).getForeign().replaceAll("\\n"," ");
bible.get(c).getForeign().replaceAll("\\r"," ");
}
the code
bible.get(c).getForeign()
returns a String in a different language that is read in from a text file. Is there anything wrong with this code? It doesn't seem to replace the new lines with spaces. I checked the JavaDocumentation on the String class and for the
replaceAll(String str, String replacement);
they said that backslashes and dollar signs might make the returned string a little different. Is there another way to do this? Thanks in advance.