i get a big string from a web page and its like this
"07:10Ο ΑΣΔΦΑΣΔΦ07:30ΑΣΔΦΑΣΔΦ10:15ΝΑΣΔΦΑΣΔΦ"
and i want every time i find time like this “17:50” or “07:30” to get a new line before the time! so i will have
07:10 ΑΣΔΦΑΣΔΦ
07:30 ΑΣΔΦΑΣΔΦ
10:15 ΝΑΣΔΦΑΣΔΦ
etc…
but here is my problem i tried to copmare the letters with this
StringBuilder builder = new StringBuilder(text);
for (int i = 0; i < text.length(); i++) {
if(Character.isDigit(text.charAt(i))){
builder.insert(i, "\n");
}
}
but inside my text i have Greek letters so the isDigit returns 1 when it gets some Greek letters. Anyone has any idea how to solve this?
To provide some initial help, the builder.insert() line isn’t doing what you probably want:
Do you really want `\n1\n2:\n4\n5″ for the string “12:45”?
You might just want to match
"\\d\\d[:.]\\d\\d"and prepend “\n” postpend ” ” on each match, but I can’t be certain I understand your problem.Specifically, I just tried:
Does this work the way you want? My terminal doesn’t seem to support these characters very well, so I may have a locale encoding issue.