Here's what I want, there's a string like, CHAR_27[19;50H
and I want to get the numbers from the inside separately.
// CHAR_27 = Character.toString( (char)27 );
// Or "\u001B"
String escapeString = "CHAR_27[19;50H";
String coord = escapeString.replaceAll("[^0-9;]", "");
List<String> coords = Splitter.on(";").splitToList(coord);
if (coords.size() != 2) continue;
rowIndex = Integer.parseInt(coords.get(0)) - 1;
colIndex = Integer.parseInt(coords.get(1)) - 1;
But sometimes it throws a NumberFormatException, invalid integer CHAR_27[19
.
Mostly it works fine.
Is there something wrong with my regex?
Or should I use StringUtils.removePattern()
for a more consistent result?
I got this report from Nokia_N1 and GT-810(rolex). Both of them are Android 5.1.
And I'm using Android API 24.