我想寫一個正則表達式,它在字符串的開頭找到時間。 我想刪除字符串的那部分,所以我使用的是regioEnd函數,但它將該區域的行尾設置爲 。Java的正則表達式區域
Pattern pattern = Pattern.compile("\\d+.\\d+");
String line = "4:12testline to test the matcher!";
System.out.println(line);
Matcher matcher = pattern.matcher(line);
int index = matcher.regionEnd();
System.out.println(line.substring(index));
我在做什麼錯在這裏?
無需發佈答案的問題的一部分。相反,只是標記正確的答案像[this](http://meta.stackexchange.com/a/5235/186652) – Pshemo