try{
p("192.168.0.aaa".matches("\\d{1,3}\\.\\d{1-3}\\.\\d{1,3}\\.\\d{1,3}"));
}catch (PatternSyntaxException e){
e.printStackTrace();
}
报错:java.util.regex.PatternSyntaxException: Unclosed counted closure near index 13
\d{1,3}\.\d{1-3}\.\d{1,3}\.\d{1,3}
^
at java.util.regex.Pattern.error(Unknown Source)
at java.util.regex.Pattern.closure(Unknown Source)
at java.util.regex.Pattern.sequence(Unknown Source)
at java.util.regex.Pattern.expr(Unknown Source)
at java.util.regex.Pattern.compile(Unknown Source)
at java.util.regex.Pattern.<init>(Unknown Source)
at java.util.regex.Pattern.compile(Unknown Source)
at java.util.regex.Pattern.matches(Unknown Source)
at java.lang.String.matches(Unknown Source)
at Test.SimpleRegular.main(SimpleRegular.java:24) |
|