how do i pull the "16" out for both
- Bar Foo Bar: Foo8:16 Foo Bar Bar foo barz
- 8:16 Foo Bar Bar foo barz
Here is what i have tried
String V,Line ="Bar Foo Bar: Foo8:16 Foo Bar Bar foo barz";
V = Line.substring(Line.indexOf("([0-9]+:[0-9]+)+")+1);
V = V.substring(V.indexOf(":")+1, V.indexOf(" "));
System.out.println(V);
And here is the error i get
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: -9
at java.lang.String.substring(String.java:1955)
at Indexing.Index(Indexing.java:94)
at Indexing.main(Indexing.java:24)
I tested the regex("([0-9]+:[0-9]+)+") at http://regexr.com/ and it correctly highlight the "8:16"