java替换html中的样式
生活随笔
收集整理的這篇文章主要介紹了
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);}}
推薦一個不錯的調試正則的網址:http://tool.chinaz.com/regex/
替換結果如下:
<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中的样式的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: vue.js使用例子
- 下一篇: [编程题]表达式合法判断