根据要求提供更完整的解决方案:
public static int indexOf(Pattern pattern, String s) { Matcher matcher = pattern.matcher(s); return matcher.find() ? matcher.start() : -1;}呼叫:
int index = indexOf(Pattern.compile("(?<!a)bc"), "abc xbc");
根据要求提供更完整的解决方案:
public static int indexOf(Pattern pattern, String s) { Matcher matcher = pattern.matcher(s); return matcher.find() ? matcher.start() : -1;}呼叫:
int index = indexOf(Pattern.compile("(?<!a)bc"), "abc xbc");