String.indexOf (String str) does not accept a regular expression. A string is required.
You can simply do this:
String V, Line = "Bar Foo Bar: Foo8:16 Foo Bar Bar foo barz"; V = Line.substring(Line.indexOf("16"), Line.indexOf("16") + 2); System.out.println(V);
To make it look neat, you can replace this line:
V = Line.substring(Line.indexOf("16"), Line.indexOf("16") + 2);
with:
int index = Line.indexOf("16"); V = Line.substring(index, index + 2);
source share