求某个字符在字符串中的第5个位置

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的位置了
原文地址:https://www.cnblogs.com/mcahkf/p/5121974.html