import java.util.regex.Matcher; import java.util.regex.Pattern; public class Text { public static void main (String [] args) { Pattern p = Pattern.compile ("b"); Matcher m = p.matcher("hi buddy! How is bill?"); while (m.find ()) { System.out.println ("Match started at:"+ m.start(0)); System.out.println ("Match ended at:"+m.end(0)); } } }
运行结果:
Match started at:3
Match ended at:4
Match started at:17
Match ended at:18
请求大神讲一下17和18是怎么得来的呀
皇4
蜂之谷
相关分类