java 的正则表达式是什么意思?

private final static Pattern URL_PARAMS_PATTERN = Pattern
.compile("carbrand=brand-\\d+(&index=\\d+)?");

第1个回答  2014-05-24
就是检查字符串是否符合某个格式
看我的例子

public class Judge
{
public static void main(String[] args)
{
String a="\\w{0,}\\@?\\w{0,}\\.{1,}\\w{0,}";
String str1="aaaa@";
String str2="aaaa";
String str3="aaaaa@111.com";
if(str1.matches(a)){
System.out.println(str1+"是1个E—mail地址格式");
}if(str2.matches(a)){
System.out.println(str2+"是1个E—mail地址格式");
}if(str3.matches(a)){
System.out.println(str3+"是1个E—mail地址格式");
}else{System.out.println("都不是1个E—mail地址格式");

}

}
第2个回答  2014-05-24
匹配 这样格式 的字符:
carbrand=brand-多个连续数字(&index=多个连续数字)括号内容出现1次或不出现。

能够匹配的字符串可能如下
carbrand=brand-123456
或者
carbrand=brand-123456&index=123456本回答被网友采纳

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网