我们如何删除出现在字符串末尾的标签?删除出现在字符串末尾的标签
Input
String test ="test string<.div class="og></div..>"
outPut
String test ="test string";
打印时我只想要test string
。字符串测试有时包含除div标签以外的标签。如何解决这个问题?
我们如何删除出现在字符串末尾的标签?删除出现在字符串末尾的标签
Input
String test ="test string<.div class="og></div..>"
outPut
String test ="test string";
打印时我只想要test string
。字符串测试有时包含除div标签以外的标签。如何解决这个问题?
使用正则表达式来处理这样的:
String test ="test string<div class=og></div>";
String regExp = "<div \\S*</div>";
String[] result = test.split(regExp);
System.out.println(result[0]);
有些时候在字符串测试包含标签非div标签 – chinchu 2012-01-03 12:37:41
String result = test.split(“<”)[0];
它返回空字符串 – chinchu 2012-01-03 12:30:21
所以告诉我们一切?... – 2012-01-03 13:12:23
你想要什么到底是什么?你想删除所有标签吗?请发布示例输入和输出。 – 2012-01-03 12:27:12
为什么他们在字符串开头?你想解析HTML吗? – Deco 2012-01-03 12:27:53
雅,从XML解析的内容是在字符串测试 – chinchu 2012-01-03 12:31:10