没有。
WorkAround:
它不是标准的做法,但你可以使用这个结果。
更新:
CharSequence inputStr = "abcabcab283c";
String patternStr = "[1-9]{3}";
Pattern pattern = Pattern.compile(patternStr);
Matcher matcher = pattern.matcher(inputStr);
if(matcher.find()){
System.out.println(matcher.start());//this will give you index
}
要么
Regex r = new Regex("YOURREGEX");
// search for a match within a string
r.search("YOUR STRING YOUR STRING");
if(r.didMatch()){
// Prints "true" -- r.didMatch() is a boolean function
// that tells us whether the last search was successful
// in finding a pattern.
// r.left() returns left String , string before the matched pattern
int index = r.left().length();
}