一个新手正则匹配问题 额 你肯能理解错了 我的意思是把<ca><pre>(.+?)</pre></ca> 懂了吧。。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 String s = "<cd><pre>不需要</pre></cd><ca><pre>需要1</pre></ca><cn><pre>需要2</pre></cn>"+"<cn><pre>需要3</pre></cn>";String reg = "<pre>(.*?)</pre>";Matcher match = Pattern.compile(reg).matcher(s);while(match.find()){ System.out.println(match.group(1));} String s = "<cd><pre>不需要</pre></cd><ca><pre>需要1</pre></ca><cn><pre>需要2</pre></cn>"+"<cn><pre>需要3</pre></cn>";String reg = "(?<=<ca><pre>).*?(?=</pre></ca>)|(?<=<cn><pre>).*?(?=</pre></cn>)";Matcher match = Pattern.compile(reg).matcher(s);while(match.find()){ System.out.println(match.group());} 我也学Java了为什么楼主问的问题我一点都不懂呢,真是惭愧啊,大学白上了 【讨论】Java的关键字new为什么不取消呢? 询问一段关于String的简单程序 元旦里随便写的,大家帮我看看我现在是面向对象的思想了吗 本机运行没问题,传到服务器applet总提示noClassDefFoundError??? j2ee配置问题,问题不大,一天都没有结果 请问这道题小题目怎么做(请想练手的看过来,有分) (100分求源码或设计思路,分不够可在加!)实现数组排序问题? 请问一下怎么判断鼠标单击,双击,左键,右键呢? 最大公约数的问题 提问:关于javadoc 今天遇到的诡异问题,保证你开眼界 str为null,str==null会不会报空指针异常
String s = "<cd><pre>不需要</pre></cd><ca><pre>需要1</pre></ca><cn><pre>需要2</pre></cn>"+
"<cn><pre>需要3</pre></cn>";
String reg = "<pre>(.*?)</pre>";
Matcher match = Pattern.compile(reg).matcher(s);
while(match.find()){
System.out.println(match.group(1));
}
String s = "<cd><pre>不需要</pre></cd><ca><pre>需要1</pre></ca><cn><pre>需要2</pre></cn>"+"<cn><pre>需要3</pre></cn>";
String reg = "(?<=<ca><pre>).*?(?=</pre></ca>)|(?<=<cn><pre>).*?(?=</pre></cn>)";
Matcher match = Pattern.compile(reg).matcher(s);
while(match.find()){
System.out.println(match.group());
}