有必要用到正则表达式吗??
直接检测<p>和</p>不就行了??
直接检测<p>和</p>不就行了??
解决方案 »
- 如何使 JTable 充满 JScrollPane
- String类的charAt方法
- 为什么子窗口不显示组件?
- JAVA如何做游戏(100分)
- 关于 java RCP开发的
- 这样的正则表达式怎样写????????
- 界面关闭的信息处理
- ******江湖救急,在线等待
- huangbrid就JDK配置的问题答谢各位参与和建议!flyzhen,yuechun,IMarksma,sonic616,erato,eyeieye,blackcats,awing_feeling,YANGJB
- PrintWriter(OutputStream out, boolean autoFlush) 中的out参数为什么可以传入FileWriter对象
- 请教各位,我用frontpage中插入applet却显不出来为什么??
- 重新回到java阵营,大散分(500)(请斑竹留情)元旦后就揭帖,祝各位新年快乐!大家的努力会让冬天赶快过去,呵呵!
import java.util.regex.*;public class test {
public static void main(String args[]) {
String str="<p>test1test2</p>";
String str1="(<p>)(.+)(<\\/p>)";
java.util.regex.Pattern p=Pattern.compile(str1);
Matcher m=p.matcher(str);
boolean f=m.find();
StringBuffer sb=new StringBuffer();
while(f) {
m.appendReplacement(sb,"$2");
f=m.find();
}
m.appendTail(sb);
System.out.print(sb.toString());
}
}
public class test {
public static void main(String args[]) {
String str="<p>test1test2</p>";
String str1="(<p>)(.*)(<\\/p>)";
java.util.regex.Pattern p=Pattern.compile(str1);
Matcher m=p.matcher(str);
boolean f=m.find();
StringBuffer sb=new StringBuffer();
while(f) {
m.appendReplacement(sb,"$2");
f=m.find();
}
m.appendTail(sb);
System.out.print(sb.toString());
}
}