我将尝试验证字符串是否与正则表达式匹配。
URL格式为:key=value&key=value&....
键或值可以为空。
我的代码如下:
Pattern patt = Pattern.compile("\\w*=\\w*&(\\w *=\\w*)* ");
Matcher m = patt.matcher(s);
if(m.matches()) return true;
else return false;
当我输入
one=1&two=2
时,它显示为假,而实际上应该是真的。有什么想法!
return A;
替换if A return true; else return false;
。 - Florian Albrecht