求高手!正则表达式~~ <a href="http://weibo.com/" rel="nofollow">新浪微博</a>我想扥到‘新浪微博’,其他的去掉,用string.replaceAll方法不知道怎么写正则,求高手解救~ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 string.replaceAll("\\<a[^>]*\\>(.*?)</a>","$1");菜鸟路过 str.replaceAll("\\<[^>]*\\>",""); String text = "<a href='http://weibo.com/' rel='nofollow'>新浪微博</a>"; text = text.replaceAll("^<.*?>(.+?)</a>", "$1"); System.out.println(text); String s="<a href=\"http://weibo.com/\" rel=\"nofollow\">新浪微博</a>".replaceAll("\\<a[^>]*\\>(.*?)</a>","$1"); System.out.println(s);测过可以 大哥,String是不可变类型,你应该把string引用重新赋值 public static void main(String[] args) { String src = "新浪微博"; String str = "<a href=\"http://weibo.com/\" rel=\"nofollow\">新浪微博</a>"; int start = str.indexOf(src); int ent = start + src.length(); System.out.println(str.substring(start, ent)); String regex = "[a-z\".:\\/<>= ]"; System.out.println(str.replaceAll(regex, "")); } String text = "<a href=\"http://weibo.com/\" rel=\"nofollow\">新浪微博</a>"; text = text.replaceAll("<[^>]+>", ""); System.out.println(text); java 异常 想做一个java闹钟,有人做过没 transient关键字是什么意思? 已经照书抄了,还是不行,对了几小时,头都晕了,大侠救命 谁能下为例解释下池、栈、堆这三个东东啊 这段代码有什么问题? 怎样实现按回车的事件! 关于TextArea组件的问题 关于使用java开发电力配网系统的问题 那个函数可以截取String有效部分 ? eclipse3.1 complier compliance level 没有6.0和1.6 java se小程序求大神解释
String text = "<a href='http://weibo.com/' rel='nofollow'>新浪微博</a>";
text = text.replaceAll("^<.*?>(.+?)</a>", "$1");
System.out.println(text);
System.out.println(s);测过可以
public static void main(String[] args) {
String src = "新浪微博";
String str = "<a href=\"http://weibo.com/\" rel=\"nofollow\">新浪微博</a>";
int start = str.indexOf(src);
int ent = start + src.length();
System.out.println(str.substring(start, ent));
String regex = "[a-z\".:\\/<>= ]";
System.out.println(str.replaceAll(regex, ""));
}
text = text.replaceAll("<[^>]+>", "");
System.out.println(text);