初学者求请教java正则表达式,匹配不成对的把该字符初始化null,求指点,谢谢了 正则表达式javastring 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 就是判断,没有条件,输入一段字符串,if(=){str}else{null}就这样 jdk自带的正则表达式验证Pattern pattern = Pattern.compile(regex) // 参数是正则表达式Matcher matcher = pattern.matcher(input) // 参数是要匹配的字符串boolean b = matcher.matches(); 谢谢Illegal repetition这个错误怎么处理? 谢谢Illegal repetition这个错误怎么处理?我不太擅长写正则表达式,只是知道怎么用,这个可能帮不到你了,你可以百度一下 谢谢Illegal repetition这个错误怎么处理?我不太擅长写正则表达式,只是知道怎么用,这个可能帮不到你了,你可以百度一下哦 好吧 谢谢 public static void main(String[] args) { // {"":"","":[],[]} 或者{"":{}} Pattern p1 = Pattern .compile("(\\{\".*?\"\\:\".*?\",\"\".*?\\:\\[.*?\\],\\[.*?\\]\\})(\\{\".*?\"\\:\\{.*?\\}})"); String str = "sasasas"; String test = "asasasascc{\"a\":{}}"; String test2 = "asasasascc{\"\":{asdf}}"; Matcher m = p1.matcher(str); if (!m.find(1) && !m.find(2)) { str = null; } System.out.println(str); Matcher m2 = p1.matcher(test); if (!m2.find(1) && m2.find(2)) { test = null; } System.out.println(test); Matcher m3 = p1.matcher(test2); if (!m3.find(1) && m3.find(2)) { test2 = null; } System.out.println(test2); }这个符合要求不 HQL模糊查询后面的 and 条件不起作用。 struts2标签<s:if> java web设置问题 问个动态页面和静态页面转换的问题 myeclipse8.0安装svn插件的问题 XML封装结构 请strurs高手指教 現在類似struts的比較新的用java開發的技術是什麽 Java Posty一个二进制流 为什么.服务器接收到为空? junit测试问题 求助!ssh框架,页面取list值 java比较大小 到底是用 Comparable接口还是Comaprator接口
Illegal repetition这个错误怎么处理?
Illegal repetition这个错误怎么处理?我不太擅长写正则表达式,只是知道怎么用,这个可能帮不到你了,你可以百度一下
Illegal repetition这个错误怎么处理?我不太擅长写正则表达式,只是知道怎么用,这个可能帮不到你了,你可以百度一下
哦 好吧 谢谢
public static void main(String[] args) {
// {"":"","":[],[]} 或者{"":{}}
Pattern p1 = Pattern
.compile("(\\{\".*?\"\\:\".*?\",\"\".*?\\:\\[.*?\\],\\[.*?\\]\\})(\\{\".*?\"\\:\\{.*?\\}})"); String str = "sasasas";
String test = "asasasascc{\"a\":{}}";
String test2 = "asasasascc{\"\":{asdf}}"; Matcher m = p1.matcher(str);
if (!m.find(1) && !m.find(2)) {
str = null;
}
System.out.println(str); Matcher m2 = p1.matcher(test);
if (!m2.find(1) && m2.find(2)) {
test = null;
}
System.out.println(test);
Matcher m3 = p1.matcher(test2);
if (!m3.find(1) && m3.find(2)) {
test2 = null;
}
System.out.println(test2);
}
这个符合要求不