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...

18,511 Responses

  1. Barrybib表示:

    Tadalafil Tablet: Max Pills For Men – Buy Tadalafil 20mg

  2. RogerFaf表示:

    http://fastpillsformen.com/# Generic Viagra online

  3. Charlesbot表示:

    http://fastpillsformen.com/# sildenafil online

  4. Donaldabula表示:

    best online ed meds FastPillsEasy cheap ed pills online

  5. Charlesbot表示:

    https://maxpillsformen.com/# Buy Tadalafil 20mg

  6. Charlesbot表示:

    https://fastpillseasy.com/# how to get ed meds online

  7. ulylcejsg表示:

    Blend and smudge out your line for a bolder, badder look. For the latest information, it is recommended to review the ingredient list printed on the packaging of the product prior to usage or consumption. This is so far the best that works with my oily eyelids, and watery eyes! The color is nice and subtle for daily wear. *This Free Gift will automatically be added to your order I know I said I was gonna do The Balm Cosmetics part 2 tonight but I decided to blog about something really short just cause I haven’t taken pictures of the other The Balm products. My bad! A Pink & Plum Eye Look ft. Sydney Grace x Temptalia !כל התגובות שאינן קשורות למוצר יימחקו Become a member and enjoy exclusive benefits: I am so missing the original bad gal liner waterproof pencil. Why did you replace it with the bad gal bang? At least give those of us who were the original buyers a choice. Very disappointing.
    http://qahmausinby1977.cavandoragh.org/eyeliner-you-review
    Duplicate a high-end product or never buy the same shade twice. The Dupe List is here to help. INGREDIENTS (INCI): Mica, Kaolin, Cocos nucifera oil*, Simmondsia chinensis oil*, Tapioca starch*, Calendula officinalis flower extract*, Hippophae rhamnoides fruit extract*, Chamomila recutita flower extract*. May contain** + – CI 77007, CI 77491, CI 77492, CI 77499, CI 77891, CI 77742, CI 77947 *Made with a minimum of 15% organic ingredients. 100% natural **Ecocert-approved iron oxide pigments (extremely pure: free from lead, arsenic, cadmium and other heavy metals) Gold isn’t just for a big night out. Blended subtly on your brow bone and the inside corner of your eye, it can give your nude day look a bit of pizzazz. Washed over your lid under a muted crease color, it will give your eyeshadow polish and life while remaining understated enough for the office. If you want to go big with a shimmery eye at night, a few variations on gold will make your smoky eye glamorous.

  8. pfovngqaf表示:

    Featuring a unique, nourishing formula, the LashForce eyelash serum from NYK1 is designed to promote longer, thicker lashes. Toplash serum will help to grow long eyelashes and smooth, beautiful eyebrows. The serum activates hair growth several times and gives a quick visible effect. The product was created as a safe alternative to eyebrow tattooing and eyelash extension. Serum tests have proven that the formula works. Many women think about why their eyelashes fall out and whether they need to strengthen them in general? This question is really important, because you need to take into account that the main purpose of eyelashes is protection. With the help of hairs, each person protects his eyes from different grains that can randomly get into his eyes. At the same time, we are also talking about dirt, flying insects and dust floating in the air.
    https://www.retecool.com/author/maheacockwer1987/
    The collection and processing of information about your use of this service to subsequently personalise advertising and or content for you in other contexts, such as on other websites or apps, over time. Typically, the content of the site or app is used to make inferences about your interests, which inform future selection of advertising and or content. What does Pride mean to you today?“It’s a time to celebrate, uplift, and honor trans people, especially trans femmes and Black trans femmes. In our queer community, these are people who have been on the front lines fighting for queer rights.” USERS SAID: \”This lash primer does exactly what I need. I use it as a base to hold my mascara in place all day—not a smudge or fleck touches my lid or cheek. With this primer, my lashes are emphasized and look natural for my workday make-up application.\”

  9. скорая наркологическая помощь на дому в москве скорая наркологическая помощь на дому в москве .

  10. Charlesbot表示:

    http://maxpillsformen.com/# Cialis 20mg price in USA

  11. RogerFaf表示:

    http://fastpillsformen.com/# Viagra online price

  12. BrettTIT表示:

    best online ed treatment: fast pills easy – online ed medications

  13. The 10 Worst L Shape Leather Sofa Fails Of All Time Could Have
    Been Prevented Two seater leather sofa

  14. BrettTIT表示:

    cialis for sale: Generic Tadalafil 20mg price – Cialis 20mg price

  15. BrettTIT表示:

    Viagra online price: FastPillsForMen.com – Generic Viagra online

  16. Donaldabula表示:

    Cialis 20mg price Cialis over the counter Generic Cialis without a doctor prescription

  17. Barrybib表示:

    ed doctor online: erectile dysfunction online prescription – ed meds cheap

  18. как вызвать наркологическую скорую помощь в москве как вызвать наркологическую скорую помощь в москве .

  19. RogerFaf表示:

    https://fastpillsformen.com/# Sildenafil Citrate Tablets 100mg

  20. Donaldabula表示:

    online ed drugs cheap cialis erectile dysfunction pills for sale

  21. yiedhyroa表示:

    This is a light, grease-less gel that helps to smooth out fine lines and wrinkles around the eyes. It also helps to lift the eye ares. It’s a great product and I always replace the bottle when I am running out. Great eye treatment product. You can receive 50 rewards points by sharing your honest opinion of EltaMD Renew Eye Gel. This product is amazing! Takes the puffiness away from under my eyes. And at 60+ us women need all the help we can get… You can receive 50 rewards points by sharing your honest opinion of EltaMD Renew Eye Gel. Niacinamide (Vitamin B3):  Anti-inflammatory that reduces redness and minimizes the appearance of dry or damaged skin and restores suppleness Have an account? Log in to see your cart items. Glycosaminoglycans: Increases collagen support for blood vessels and skin to reduce or stop dark circles under eyes
    https://lifewebdirectory.com/listings12864737/best-glossier-makeup-products
    This is what my leg looks like after not shaving for a WEEK AND A HALF. I am basically in awe that this device works exactly as it says it will. I guess I am always slightly skeptical of products at first because of the industry I am in. There are so many products that don’t do what they say they will do, and let’s face it, being able to do laser hair removal at home seems almost too good to be true. It’s not. This is what my leg looks like after not shaving for a WEEK AND A HALF. I am basically in awe that this device works exactly as it says it will. I guess I am always slightly skeptical of products at first because of the industry I am in. There are so many products that don’t do what they say they will do, and let’s face it, being able to do laser hair removal at home seems almost too good to be true. It’s not.

  22. Barrybib表示:

    buy ed pills: cheap cialis – top rated ed pills

  23. kqsmpvdvx表示:

    Help Me Pick Sheet Masks Japan KissMe Japan KissMe IngredientsIsodecane, Trimethylsiloxysilicic Acid, Hydrogenated Polyisobutene, Ceresin, Beeswax, Disteardimonium Hectorite, (Palmitic Acid Ethylhexanoic Acid) Dextrin, Microcrystalline Wax, Propylene Carbonate, Polymethylsilsesquioxane, Canina Rose Fruit Oil, Argania Spinosa Kernel Oil, Camellia Seed Oil, Squalane, Royal Jelly Extract, Ptfe, Distearic Acid Al, Glyceryl Isostearate, Talc, Iron OxideMade in Japan These cookies are used to deliver advertisements that are more relevant to you and your interests. Marketing Cookies are placed by third-party providers with our permission, and any information collected may be shared with other organizations such as publishers or advertisers. These cookies are required to use core website features and are automatically enabled when you use the site. They also enable use of the Shopping Bag and Checkout processes, assist in regulatory and security issues, measure traffic and visits, and retrieve order information for affiliate commissions. We use the information collected to evaluate and improve the performance of your shopping experience.
    https://www.intensedebate.com/people/makeuprevolutio
    Committed to creating clean, conscious formulas that are kind to both your skin and the planet, bareMinerals are renowned for mineral makeup, seeking to enhance natural beauty. The Original Loose Powder Foundation is a true cult-classic, with one sold every 18 seconds. The brand also pioneers clean, vegan skincare designed to enhance radiance and promote a healthy-looking complexion. Look, feel and do good with bareMinerals’ award-winning beauty staples. Excess oil doesn’t stand a chance against this budge-proof primer that ups the intensity of your eye makeup. It also brightens eyes and creates a smooth base for makeup. Even though it’s light as a feather and goes on sheer, it lasts all day—and all night. Silky and lightweight, this eye primer ensures smooth, striking eyecolor application and ultra-long wear

  24. RogerFaf表示:

    http://fastpillsformen.com/# Sildenafil Citrate Tablets 100mg

  25. Charlesbot表示:

    https://maxpillsformen.com/# cialis for sale

  26. Donaldabula表示:

    Cialis without a doctor prescription buy cialis online Buy Tadalafil 20mg

  27. 9 Things Your Parents Taught You About Lawyer Train big truck accident lawyer

發佈留言

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