java替换html中的样式
来源:互联网 发布:午夜美女软件 编辑:程序博客网 时间:2024/06/01 22:38
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/
0 0
- java替换html中的样式
- Jsoup-Java解析Html类库,替换img标签style样式
- java 替换文本内容中的html标签
- html中的css样式
- java中替换html标签
- java替换包含html标签
- Java参数中的\替换
- Java中的字符替换
- Java中的字符替换
- 替换JAVA Doc的样式表
- 替换、恢复Html中的特殊字符
- 替换,恢复html中的特殊字符
- 怎样替换html中的iframe标签
- javascript html页面中的内容替换
- 对html字符串中的src进行替换
- 替换xml/html中的属性值
- html页面中的各种鼠标样式
- javascript操纵html中的css样式 五
- 数组中出现次数超过一半的数字(java版)
- (三)R语言-从数据源获取数据
- codefoces #409
- 新浪云安装Carbon Forum出现无法注册的问题
- web Storage(临时储存和本地储存)
- java替换html中的样式
- 计算分数的精确值
- git clone 远程分支
- linux多线程-懒人笔记(一)
- git push & git pull 推送/拉取分支
- 159.n1-点击RadioGroup切换ViewPager
- Python 标准库 csv —— csv 文件的读写
- linux下安装或升级GCC4.8,以支持C++11标准
- Android中 dp,px,dpi三者之间的关系