how can i find the last visible character in a Java String? I'd like to remove all line breaks and other invisible characters from a Java String
Kind Regards, Tord
how can i find the last visible character in a Java String? I'd like to remove all line breaks and other invisible characters from a Java String
Kind Regards, Tord
string_variable.replaceAll("\\p{C}", "?");
This will replace all non-printable characters. Where p{C} selects the invisible control characters and unused code points.
You can use the trim()
method of the String
class for removing trailing (and leading) white space and line breaks:
String trimmed = original.trim();