Java的方式向HTML形式的字符串中指定位置插入信息
来源:互联网 发布:c语言swap 编辑:程序博客网 时间:2024/06/03 13:40
public String setNewDescription(String descriptions) {
String message = "this is message";
Pattern filter = Pattern.compile("<div class=\"item-description\".*?>[\\s\\S]*?</div>", Pattern.CASE_INSENSITIVE);
Matcher filterMatcher = filter.matcher(descriptions);
String content = null;
if(filterMatcher.find()) {
content = filterMatcher.group();
}
StringBuffer sb = new StringBuffer(content);
sb.insert(content.lastIndexOf("</div>"), message);
return descriptions.replaceAll("<div class=\"item-description\".*?>[\\s\\S]*?</div>", sb.toString());
}
String message = "this is message";
Pattern filter = Pattern.compile("<div class=\"item-description\".*?>[\\s\\S]*?</div>", Pattern.CASE_INSENSITIVE);
Matcher filterMatcher = filter.matcher(descriptions);
String content = null;
if(filterMatcher.find()) {
content = filterMatcher.group();
}
StringBuffer sb = new StringBuffer(content);
sb.insert(content.lastIndexOf("</div>"), message);
return descriptions.replaceAll("<div class=\"item-description\".*?>[\\s\\S]*?</div>", sb.toString());
}
阅读全文
0 0
- Java的方式向HTML形式的字符串中指定位置插入信息
- 向字符串中指定位置插入字符
- 删除字符串中指定位置的字符
- 删除字符串中指定位置的字符
- 查找字符串中指定字符的位置
- 查找字符串中指定字符的位置:
- 在数组中指定的位置插入一个数.
- 可编辑div中指定位置插入内容的方法
- 获取字符串中指定字符最后一次出现的位置
- Python:字符串中指定位置插入一个字符
- JAVA 如何获取Vector变量中指定位置的元素
- JAVA基础 - 删除字符串中指定字符串的方法
- SQL2008 在一个表中指定的列位置插入一个新列的方法
- 字符串中指定字符串的替换
- 删除字符串中指定的字符串
- js获取一个字符串中指定字符串第n次出现的位置
- 修改数据表中指定记录的信息
- 如何在Tomcat中指定log文件的位置(使用log4j输出log信息)
- 数据结构(Java)---单链表的转置问题
- 基于TLS1.1协议学习笔记
- 关于网页载入,页面顶部显示页面加载线性进度条效果实现。
- 求1+2!+3!+...+20!的和
- 投资感悟
- Java的方式向HTML形式的字符串中指定位置插入信息
- PAT——1016部分A+B
- js中同步与异步
- 关于系统安全性的几个概念
- 1024 多组最大字段和 循环使用优化
- JAVA中this的三种用法的详解
- npm换源
- arm linux开发环境搭建
- Jupyter Notebook 使用简介