Java 正则 , 截取两个标签之间字符串 :
String testStr = "12315<Test>show me</text>";
Pattern p = Pattern.compile("<Text>(.*)</Text>");
Matcher m = p.matcher(testStr);
while(m.find()){
System.out.println(m.group(1));
}
如上, 控制台输出应为:show me.
本文介绍了一种使用Java正则表达式从特定格式的字符串中提取内容的方法。通过一个具体的例子展示了如何匹配并获取两个HTML标签之间的文本内容。
Java 正则 , 截取两个标签之间字符串 :
String testStr = "12315<Test>show me</text>";
Pattern p = Pattern.compile("<Text>(.*)</Text>");
Matcher m = p.matcher(testStr);
while(m.find()){
System.out.println(m.group(1));
}
如上, 控制台输出应为:show me.
1287
621

被折叠的 条评论
为什么被折叠?