java替换html中的样式
package com.yz.yrh.integration;import java.util.regex.Pattern;/*** Created by Administrator on 2017/5/12.*/
public class RegexTest {public static void main(String [] args){String content="<p align=\"center\"> \t<b><span>耶稣就是答案</span></b> </p> <p align=\"center\"> \t<strong>作者:道格·巴契勒\n" +"\n" +"</strong> </p> <p align=\"left\"> \t<br /> </p> <p align=\"left\"> \tC Em F Dm Am </p> <p \n" +"\n" +"align=\"left\"> \tWhen I gaze up at the countless stars or on an endless sea, </p> <p align=\"left\"> \t当我凝视无\n" +"\n" +"垠的星空和无际的海洋 </p> <p align=\"left\"> \tE E7 Am D7 G G7 </p> <p align=\"left\"> \tMy mind may swim \n" +"\n" +"with questions, bewildering to me, </p> <p align=\"left\"> \t无数问号,在我心海里聚集彷徨, </p> <p \n" +"\n" +"align=\"left\"> \tF Dm Em Am F G7 C </p> <p align=\"left\"> \tBut then I look into Your book and seek Your face \n" +"\n" +"in prayer, </p> <p align=\"left\"> \t当我打开圣经,在祷告中寻求主面, </p> <p align=\"left\"> \tF Dm C Am \n" +"\n" +"F G7 C C7 </p> <p align=\"left\"> \tI’m satisfied remembering Your loving grace and care. </p> <p \n" +"\n" +"align=\"left\"> \t祢的慈恩与眷顾,总使我饱足欢畅 </p> <p align=\"left\"> \t<br /> </p> <p align=\"left\"> \t\n" +"\n" +"<b>副歌</b> </p> <p align=\"left\"> \tF G7 C Am F G Em </p> <p align=\"left\"> \tWhatever questions I may \n" +"\n" +"have whether great or small, </p> <p align=\"left\"> \t尽管心中装满问号,或大或小 </p> <p align=\"left\"> \tF \n" +"\n" +"G7 G Em Am </p> <p align=\"left\"> \tI know Jesus died to save me, and that He forgave me, </p> <p \n" +"\n" +"align=\"left\"> \t但我知救赎的主、赦我罪,将我恩膏! </p> <p align=\"left\"> \tF G7 C A A7 F G7 C </p> <p \n" +"\n" +"align=\"left\"> \tJesus is the answer to it all --- Jesus is the answer to it all. </p> <p align=\"left\"> \t耶\n" +"\n" +"稣是所有疑问的答案 耶稣是所有疑问的答案 </p> <p align=\"left\"> \tC Em F Dm Am </p> <p align=\"left\"> \tI \n" +"\n" +"have so many questions, I wonder in my heart, </p> <p align=\"left\"> \t许许多多的问题 在我心中辗转: \n" +"\n" +"</p> <p align=\"left\"> \tE E7 AM D7 G G7 </p> <p align=\"left\"> \tHow something comes from nothing? \n" +"\n" +"When did forever start? </p> <p align=\"left\"> \t无中怎能生有? 何处是永恒之源? </p> <p align=\"left\"> \t\n" +"\n" +"F Dm Em F G7 C </p> <p align=\"left\"> \tWhy can’t I see Your glory? Where is the Promised Land? </p> <p \n" +"\n" +"align=\"left\"> \t为何祢的荣光我不得见, 哪里有应许的地土山川? </p> <p align=\"left\"> \tF Dm C Am F G7 C C7 </p> \n" +"\n" +"<p align=\"left\"> \tI’ll trust that You will lead me there if I can take you hand. </p> <p align=\"left\"> \t\n" +"\n" +"我相信只要抓紧祢的手,就必见到主面。 </p> <p align=\"left\"> \t<br /> </p> <p align=\"left\"> \t<b>副歌\n" +"\n" +"</b> </p> <p align=\"left\"> \tF G7 C Am F G Em </p> <p align=\"left\"> \tWhatever questions I may have \n" +"\n" +"whether great or small, </p> <p align=\"left\"> \t尽管心中装满问号,或大或小 </p> <p align=\"left\"> \tF \n" +"\n" +"G7 G Em Am </p> <p align=\"left\"> \tI know Jesus died to save me, and that He forgave me, </p> <p \n" +"\n" +"align=\"left\"> \t但我知救赎的主、赦我罪,将我恩膏! </p> <p align=\"left\"> \tF G7 C A A7 F G7 C </p> <p \n" +"\n" +"align=\"left\"> \tJesus is the answer to it all --- Jesus is the answer to it all. </p> <p align=\"left\"> \t耶\n" +"\n" +"稣是所有疑问的答案 耶稣是所有疑问的答案! </p>\n" +"<span style=\"color:#E53333;\">我们会定期发布视频和文章,便于手机上网者阅读和收看!</span>";//java替换html中的样式content=content.replaceAll("[a-zA-Z]*=\".*\""," ");System.out.println(content);}}
替换结果如下:
<p > <strong>作者:道格·巴契勒</strong> </p> <p > C Em F Dm Am </p> <p > 当我凝视无垠的星空和无际的海洋 </p> <p > My mind may swim with questions, bewildering to me, </p> <p > 无数问号,在我心海里聚集彷徨, </p> <p > But then I look into Your book and seek Your face in prayer, </p> <p > F Dm C Am F G7 C C7 </p> <p > I’m satisfied remembering Your loving grace and care. </p> <p > <b>副歌</b> </p> <p > Whatever questions I may have whether great or small, </p> <p > F G7 G Em Am </p> <p > I know Jesus died to save me, and that He forgave me, </p> <p > F G7 C A A7 F G7 C </p> <p > 耶稣是所有疑问的答案 耶稣是所有疑问的答案 </p> <p > I have so many questions, I wonder in my heart, </p> <p > 许许多多的问题 在我心中辗转: </p> <p > How something comes from nothing? When did forever start? </p> <p > F Dm Em F G7 C </p> <p > Why can’t I see Your glory? Where is the Promised Land? </p> <p > F Dm C Am F G7 C C7 </p> <p > 我相信只要抓紧祢的手,就必见到主面。 </p> <p > <b>副歌</b> </p> <p > Whatever questions I may have whether great or small, </p> <p > F G7 G Em Am </p> <p > I know Jesus died to save me, and that He forgave me, </p> <p > F G7 C A A7 F G7 C </p> <p > 耶稣是所有疑问的答案 耶稣是所有疑问的答案! </p>
<span >我们会定期发布视频和文章,便于手机上网者阅读和收看!</span>
推荐一个不错的调试正则的网址:http://tool.chinaz.com/regex/
java替换html中的样式相关推荐
- java替换数组中的元素_如何使用Java 8流快速替换列表中的元素
java替换数组中的元素 假设您有一个项目清单: List<String> books = Arrays.asList("The Holy Cow: The Bovine Tes ...
- java替换字符串中的 “ 双引号 并添加正 斜杠 \)
java替换字符串中的 " 双引号 并添加正 斜杠 \ java替换字符串中的 " 双引号 并添加正斜杠 \ 解决方案很多.像我一样强行死磕(吐血),或者换别的传参方式.(理论上后 ...
- java替换list中元素,Java 实例 - List 元素替换
以下实例演示了如何使用 Collections 类的 replaceAll() 来替换List中所有的指定元素: /* author by shouce.ren Main.java */ import ...
- java 替换文件中的字符串
import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.Prin ...
- JAVA 替换pdf中文字
java 读取PDF文件内容进行替换 需要使用到的包 监听类(对需要替换的内容关键词进行匹配) 实体类(保存关键字字体格式信息以及其位置) 工具类(对关键字进行替换) 测试类 需要使用到的包 ...
- java 替换pdf中的文字
1.引入依赖 <dependency><groupId>com.itextpdf</groupId><artifactId>itext-asian< ...
- Java 替换字符串中的回车换行符的方法
使用正则表达式进行替换: 代码片段: String documentTxt = EntityUtils.toString(entity,"gbk");//获取数据 documen ...
- Java 替换文件中的内容信息
应用场景: 适合内容较少的小文件,比如脚本文件 解析: 首先读取文件内容,找到要替换的文本,然后替换文本信息,将旧文件删除,创建新文件,将所有内容复制一份重写到新文件中 具体代码: import ja ...
- Java 替换字符串中空格的三种方法
1.方法分类 str.trim(); //去掉首尾空格 str.replace(" ",""); //去除所有空格,包括首尾.中间 str.replaceAll ...
最新文章
- 【采用】【风控体系】携程基于大数据分析的实时风控体系
- php开启mysqlnd,如何启用mysqlnd的PHP?
- 文档词频矩阵_论文理解:从词嵌入到文档距离
- java快捷键禁用_pycharm 掌握这些快捷键,你就是大神!!
- eclipse : java项目中的web.xml( Deployment Descriptor 部署描述文件 )配置说明
- 华为再获90天“临时许可证” 可继续维护客户
- Ace在线代码编辑器使用
- java怎么销毁session_Java中session的销毁
- python微积分求面积_用Python学微积分(微积分应用)
- Mybatis-plus代码生成器
- svn之黄色感叹号处理方法
- 81章 老子1章到_《道德经》81章全文(建议收藏)
- Reactjs鼠标滚轮监听
- ctfshow 做题 萌新 模块(1)
- 【计算机原理与接口技术(UNIX)⑱】——并行 I/O 接口 [ 芯片8255A ]
- Spinner用法案例
- 2022学Django----基础五之Ajax
- (APIO)烟火表演
- 项目进度推进——工作成果呈现
- 广告设计中心源码php,鑫跃(XYCMS)广告设计中心网站系统 v4.6
热门文章
- 12行代码AC——L1-058 6翻了(15分)
- 计算机网络实验(华为eNSP模拟器)——第四章 配置静态路由、动态路由
- 数据库mysql建立索引_为mysql数据库建立索引
- mysql bin.000013_mysql的binlog安全删除的一种方法
- centos mysql 安装 yum源_Linux - CentOS 7 通过Yum源安装 MySql 5.7
- android adb 环境,Android安卓环境搭建及ADB常用命令
- Linux系统安全与应用(一)——账号安全与控制与PAM认证模块
- java中输出时间12小时制转换为24小时制显示
- python2.7安装scrapy_python 2.7 的Scrapy安装介绍
- hdfs数据节点分发什么协议_HDFS主要节点解说(一)节点功能