Java + JS去除網頁HTML標籤

同樣是工作上用到,在前(Javascript)、後端(Java、JSP)同樣都有的一個需求,就是必須將讀入的字串去除HTML Tag,以下是兩個範例:

var HTML = "";
HTML+= "<p>HTML P Tag String</p>";
HTML+= "<p><a href='/test/link.html'>HTML A Tag String</a></p>";

var htmlTagPattern = /<{1}[^>]{1,}>{1}/g; //HTML Tag Pattern
var htmlSplit = HTML.replace(htmlTagPattern, ""); //移除HTML Tag

console.log("htmlSplit : " , htmlSplit); //輸出htmlSplit :  HTML P Tag StringHTML A Tag String
package CDIT.stanley;
public class trimHTML {
	public static void main(String[] args) {
		String HTML = "";
		HTML+= "<p>HTML P Tag String</p>";
		HTML+= "<p><a href='/test/link.html'>HTML A Tag String</a></p>";
		
		String htmlTagPattern = "<{1}[^>]{1,}>{1}"; //HTML Tag Pattern		
		String htmlSplit = HTML.replaceAll(htmlTagPattern, ""); //移除HTML Tag
		
		System.out.println("htmlSplit : " + htmlSplit); //輸出htmlSplit : HTML P Tag StringHTML A Tag String
	}
}

You may also like...

6,175 Responses

  1. Katinepisn表示:

    williams interactive slots
    slotomania free slots facebook
    sim slots

  2. rog表示:

    As you can see, there are many variables when it comes to pricing your dream kitchen. Pricing “Apples to Apples” for your new kitchen or kitchen renovation can be very difficult or virtually impossible when planning your kitchen. Please note that prices may vary in Canada from the US market. We always recommend working with a professional Kitchen Designer who can help you establish a budget, as they will keep you working towards your goal of achieving your dream kitchen. It costs an average of $37,000 to renovate both the kitchen and the bathroom. Bathroom remodels cost around $11,000 of the total. There are many remodeling contractors who are licensed to perform both projects with the help of subcontractors, so you can often hire one contractor for all the work. A general contractor will subcontract out licensed trades for plumbing, electrical, and mechanical or HVAC. https://askketo.com/community/profile/blanchedagostin/ DreamMaker franchisees offer the niche of professional kitchen and bath remodeling. The business model is designed to expand into full interior remodeling as your confidence, competency and business grows. This allows you to maximize your marketing dollars and create a customer for life. HGTV® Dream Home 2022 We believe if we treat people with respect and integrity, success will follow. Our Code of Values™ is central to who we are and the way we try to conduct ourselves in business and in life. The Code of Values™ is not just something that hangs on the wall. We have a system for keeping the Code of Values™ in place. It’s a living, breathing philosophy based on timeless principles. We know it is impossible to live these values perfectly, but we can live them with excellence — meaning when we miss one, we are willing to be held accountable in a respectful way.

  3. rog表示:

    “We wanted new granite (or similar) countertops, but with a new roof, a baby on the way, a home refi (and a few other larger expenses) we just couldn’t swing it. So I once again turned to Pinterest, where I stumbled upon this blog post with steps detailing how to pretty easily convert your existing countertops to polished concrete coated ones. We decided that this was the only way for us to go (at least for now until we are possibly ready to professionally update them in the future).” In every kitchen makeover, a common question we get asked is, “Which fixtures or elements will you upgrade?” Well, your best answer for this is to prioritize those kitchen fixtures and items which are most functional and constantly in-use when someone is preparing food in the kitchen. To make it easier for you, we’ve outlined some of the vital factors you need to include in a modern kitchen remodel. https://petentialofficial.com/community/profile/hungcissell5571/ A modern kitchen remodel design is all about having a double of everything. Two refrigerators, two sinks, and two kitchen islands too! If you try to fit all of this in a general basic kitchen, it is sure not to happen! But an open kitchen plan and easily and beautifully accommodate all of these components without cramping up space. With more space for their guests and so much more convenient storage, Rob and Katie now have a beautiful and more functional space to both create great meals and entertain guests in their Voorhees home. Do you need a kitchen remodel in your Voorhees home? Reach out to Cabinetree today and tell us about your project…we can’t wait to improve your living space! After talking to our client about her ideas and taking photos and measurements of her home, our designers got to work creating new floor plans and renderings of the remodeled rooms.

  4. baricitinib and covid treatment baricitinib tablet baricitinib cost baricitinib iupac name

  5. olumiant preis olumiant medicine synthesis of baricitinib baricitinib = sulfa drug?

  6. define furosemide furosemide 20mg furosemide 20 mg once a day what does lasix do

  7. kamagra et ejaculation commander kamagra generique quelle dose de kamagra prendre kamagra ou cialis doctissimo

  8. Katinepisn表示:

    online casino slots
    slot machines casino
    myclub888

  9. propecia dose best price generic propecia how did propecia the crackwhore die how to buy propecia online

  10. I see something genuinely special in this internet site.

  11. There is obviously a bunch to realize about this. I assume you made some nice points in features also.

  12. propecia rival crossword buy propecia online europe should i take propecia reddit dr who will prescribe propecia to female patients

  13. cenforce 100mg generic cenforce soft cenforce 200 отзывы cenforc

  14. cialis 2.5mg cialis sur ordonnance ou pas cialis ne fait pas d’effet comment demander du cialis a son medecin

  15. staxyn vs levitra viagra and cialis australia kamagra oral jelly review forum cialis how long to take effect

  16. uxqpsjqj表示:

    hydroxychloroquine sulfate 200mg purchase plaquenil online

  17. order cheap online levitra where can i buy levitra levitra bucodispersable levitra 20 milligrams

  18. neurontin opiate how much is gabapentin 300 mg neurontin withdrawal symptoms how long what is gabapentin used for?

  19. Great blog! Do you have any hints for aspiring writers? I’m hoping to start my own blog soon but I’m a little lost on everything. Would you propose starting with a free platform like WordPress or go for a paid option? There are so many options out there that I’m completely confused .. Any tips? Appreciate it!

  20. lzbsoaqx表示:

    hydroxychloroquine in canada for sale http://hydroxychloroquinex.com/

發佈回覆給「equivalent du kamagra」的留言 取消回覆

發佈留言必須填寫的電子郵件地址不會公開。