String ss="2222222222";Matcher slashMatcher1 = Pattern.compile("2").matcher(ss); int mIdx1 = 0; while (slashMatcher1.find()) { mIdx1++; if (mIdx1 == 5) { break; } } int a = slashMatcher1.start();//a就是第5个2的位置了
时间: 2024-10-05 04:10:17
String ss="2222222222";Matcher slashMatcher1 = Pattern.compile("2").matcher(ss); int mIdx1 = 0; while (slashMatcher1.find()) { mIdx1++; if (mIdx1 == 5) { break; } } int a = slashMatcher1.start();//a就是第5个2的位置了