I am reading a string of text from a source that I cannot see otherwise. I would like to see the actual formatting codes such as: \t \n
etc. instead of actual tabs and newline
When I print the String using System.out.println
, I see the tabs visually and would have to count them by highlight with the mouse.
I've tried using a regex to replace the \t
in the string with a \\t
but I have little experience with regex so I'm not sure if my expression is correct. Here's what I have:
String text = extractor.getText();
text.replaceAll("\n", "\\n");
I would appreciate an alternate method of doing this without regex if possible. I'm using an XSSFExcelExtractor
if it makes any difference.