I am writing out a String and i need it to break the lines every time there is 20 characters on a line.
However, it counts the
\n
as a character as well. How can i break the lines when there is 20 characters on the line, excluding the \n?
Edit: Every time it’ve counted 20 characters, it adds \n to the end of the line
Before printing your string, get rid of the containing line breaks like this:
Here
"\\n"is a regular expression matching the newline character. The string literal"\\n"is actually a string containing\n