我是初学者,高手半我看看,为什么我的java程序不能运行啊?
publicclassMymatch{privatestaticfinalStringREGEX="abc";privatestaticfinalStringINPUT=...
public class Mymatch{
private static final String REGEX = "abc";
private static final String INPUT = "abcdaabcabbbcabccabcaabcabba";
public static void main(String[]args){
Pattern p = Pattern.compile(REGEX);
Matcher m = p.match(INPUT);
int i = 0;
whie(m.find()); {
i++;
System.out.print("Match"+i);
System.out.print(":"+m.start());
System.out.println("-"+m.enf());
}
}
} 展开
private static final String REGEX = "abc";
private static final String INPUT = "abcdaabcabbbcabccabcaabcabba";
public static void main(String[]args){
Pattern p = Pattern.compile(REGEX);
Matcher m = p.match(INPUT);
int i = 0;
whie(m.find()); {
i++;
System.out.print("Match"+i);
System.out.print(":"+m.start());
System.out.println("-"+m.enf());
}
}
} 展开
展开全部
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Mymatch {
private static final String REGEX = "abc";
private static final String INPUT = "abcdaabcabbbcabccabcaabcabba";
public static void main(String[] args) {
Pattern p = Pattern.compile(REGEX);
Matcher m = p.matcher(INPUT);
int i = 0;
System.out.println(m.find());
while (m.find()) {
i++;
System.out.print("Match" + i);
System.out.print(":" + m.start()); //这个是返回上一次匹配的,第一次运行到的时候会出异常
System.out.println("-" + m.end()); //上一次的,第一次运行会有异常
}
}
}
import java.util.regex.Pattern;
public class Mymatch {
private static final String REGEX = "abc";
private static final String INPUT = "abcdaabcabbbcabccabcaabcabba";
public static void main(String[] args) {
Pattern p = Pattern.compile(REGEX);
Matcher m = p.matcher(INPUT);
int i = 0;
System.out.println(m.find());
while (m.find()) {
i++;
System.out.print("Match" + i);
System.out.print(":" + m.start()); //这个是返回上一次匹配的,第一次运行到的时候会出异常
System.out.println("-" + m.end()); //上一次的,第一次运行会有异常
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询