在这里,我使用正则表达式来捕获前 15 个字符进行匹配,并且在使用子字符串时我必须使用 (0,matcher.start()) ,其中我应该只得到 15,请帮助我。
String test = "hello world this is example";
Pattern p = Pattern.compile(".{15}");
//can't change the code below
//can only make changes to pattern
Matcher m=p.matches(test);
matcher.find(){
String string = test.substring(0, m.start());
}
//here it is escaping the first 15 characters but I need them
//the m.start() here is giving 0 but it should give 15