I have CharSequence source, int start, int end
I would like to strip all "control characters" from source between start and end and return this as a new CharSequence
by "control character" I mean undeseriable characters like Tab and Return, line feeds and such... basically all that was in ASCII < 32 (space) ... but I don't know how to do it in this "modern age"
what is a char
? is it unicode? How can I remove these "control characters" ?
You could use CharSequence.subSequence(int, int)
and String.replaceAll(String, String)
as follows:
source.subSequence(0, start).toString() + source.subSequence(start, end).toString().replaceAll("\\p{Cntrl}", "") + source.subSequence(end, source.length()).toString()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With