Pattern.compile,貌似是正则表达式的问题,但是我不会改。。求大神指导
Stringline="14091543758.8.8.81aaaa.bbb.cc";Stringregex="^([\\d]+)[\t]+([\\d]*\\.[\\d]...
String line = "1409154375 8.8.8.8 1 aaaa.bbb.cc";
String regex = "^([\\d]+)[ \t]+([\\d]*\\.[\\d]*\\.[\\d]*\\.[\\d]*)[ \t]([\\d]+)[ \t]+(.*)$";
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(line);
//String mm[]=line.split("^([\\d]+)[ \t]");
String aa=m.group(4);
System.out.println(aa);
Exception in thread "main" java.lang.IllegalStateException: No match found
at java.util.regex.Matcher.group(Matcher.java:536)
at test.helloword.main(helloword.java:46)
就是把line分成四部分,然后有多少空格是不确定的 展开
String regex = "^([\\d]+)[ \t]+([\\d]*\\.[\\d]*\\.[\\d]*\\.[\\d]*)[ \t]([\\d]+)[ \t]+(.*)$";
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(line);
//String mm[]=line.split("^([\\d]+)[ \t]");
String aa=m.group(4);
System.out.println(aa);
Exception in thread "main" java.lang.IllegalStateException: No match found
at java.util.regex.Matcher.group(Matcher.java:536)
at test.helloword.main(helloword.java:46)
就是把line分成四部分,然后有多少空格是不确定的 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询