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,997 Responses

  1. snorting neurontin neurontin brand name how quickly does neurontin work what is gabapentin good for?

  2. The following time I learn a blog, I hope that it doesnt disappoint me as a lot as this one. I imply, I know it was my choice to read, however I really thought youd have something fascinating to say. All I hear is a bunch of whining about one thing that you could fix for those who werent too busy looking for attention.

  3. viagra erection viagra with alcohol buy cialis online canadian pharmacy how can i get a prescription for viagra

  4. viagra tablets online viagra free trial how to get viagra prescribed when is the best time to take cialis 5mg

  5. diltiazem ointment price cardizem la 180mg diltiazem hydrochloride er 120 mg what drug in diltiazem slows heart rate

  6. kxlhhqlt表示:

    plaquenil tablets 200mg hydroxychloroquine online canada do you need a prescription for hydroxychloroquine

  7. girl takes viagra viagra australia review where can i buy viagra from kamagra tablets how do they work

  8. zanaflex versus flexeril tizanidine online no prescription can i take tylenol codeine with zanaflex how fast does zanaflex work

  9. acpssszw表示:

    hcq medication for sale hydroxychloroquine 200mg

  10. adsuwfkm表示:

    erythromycin vs azithromycin is erythromycin a sulfa drug

  11. bjajpglc表示:

    erythromycin side effects erythromycin family

  12. I think this is a real great blog. Keep writing.

  13. FM카지노表示:

    I will immediately snatch your rss as I can not find your e-mail subscription hyperlink or newsletter service. Do you’ve any? Please permit me recognise in order that I may just subscribe. Thanks.
    Feel free to surf to my website – https://main7.net/obama/

  14. sqctxjwj表示:

    erythromycin ophthalmic ointment side effects http://erythromycinn.com/#

  15. paciullo表示:

    Additionally, the functionality of this amazing software tool is enhanced by a community of creative people and a strong selection of premium and free resources.// Copyright 2001-2019 Crytek GmbH / Crytek Group. All rights reserved.

    #pragma once

    #ifndef __IResourceCountedObject_INTERFACE_H__
    #define __IResourceCountedObject_INTERFACE_H__

    #include https://www.probnation.com/upload/files/2022/06/pXqxlYDwXdidZudDW9Qi_06_b3f2dcd2f51571b3f2228f2a1e141708_file.pdf
    50e0806aeb paciullo

  16. yilcha表示:

    Even though it does not render the process fully automatic, in addition to these features, the program can still be recommended to those with weak or insufficient passwords for their WordPress credentials.
    As soon as you have the game installed, you will be able to test your skills in this online multiplayer title. In order for you to do so, you can generate a free discord invite using the listed website address.
    Instead of launching the game using your Google drive account, you can generate a free discord account https://huthamcauchuyennghiep.com/wp-content/uploads/2022/06/deschri.pdf
    50e0806aeb yilcha

  17. acccah表示:

    Try it out using the demo version for free
    If you want to try out the application all for free, then download a demo version here, which, among other things, solves the problem of automatically converting your PDF files to DOC files without the need for a source code.
    Afterwards, you can simply register for free if you want to get your hands on the full version of the app, which, in turn, will also make sure that you can carry out the type of conversions it http://iptvpascher.com/?p=1386
    50e0806aeb acccah

  18. farnhun表示:

    The startup costs for the software is about $20, for each satellite, and a clear time goal is one day.

    Each simulation is a different satellite that you can choose from. Before you pick a satellite you have to understand that you have an orbital speed. This means that the moment a satellite is launched the orbital velocity and the subsequent velocities of the satellite are preset. The orbital velocity that you are given to launch a satellite is not the final velocity, but the starting and ending https://redmoonstar.com/2022/06/06/donarius-1-0-0-117-crack-activation-code-with-keygen-for-pc-2022/
    50e0806aeb farnhun

  19. kierregn表示:

    $03

    The program name will give you a hint about what LastActivityView is all about: it helps you view the latest activity/changes recorded by your computer. After all, the Windows registry does not get updated with new entries, and files are not left behind on the HDD after program removal.

    While it is not necessary to install LastActivityView (it’s drop-and-run software) it does offer some great features:

    It is also possible to https://aiinewsline.news/wp-content/uploads/2022/06/Multi_Replacer_Lite.pdf
    50e0806aeb kierregn

  20. rozqua表示:

    The service is provided on [login to view URL] and hosted on RackSpace’s cloud infrastructure which means that the service is available 100% of the time.

    Key Features

    Free

    No issue comes as a surprise in any business. Server Benchmark is as useful as a tool that can test your server provisioning as it is for spotting foreseeable downtime. Server Benchmark provides a free service to you – that’s why it’s called it…

    High availability https://www.easydial.in/wp-content/uploads/2022/06/MediaInfo.pdf
    50e0806aeb rozqua

  21. ullrfred表示:

    Nonetheless, as long as it keeps working correctly, MyProxy is a great choice in the Windows subscription (Local Network – any connection mode).

    PANDAVPN PRO v3.0は、その老若男子向けに作られたVPNサービスながら、それゆえにF-Secureのような大手のVPN事業者ではな https://www.digitalgreenwich.com/wp-content/uploads/2022/06/verwash.pdf
    50e0806aeb ullrfred

  22. hontal表示:

    JointTrack was originally developed in 1987 for analyzing motion capture data, but has since been expanded to work with serial X-ray image sequences (3-D surface motion of bones). The data from the bodies underlying X-ray films can be displayed with in any vector, scalar or graphical format.

    JointTrack is used to analyze and represent the motions of body parts (bones), devices, tools, implants or other pieces. It can be used to analyze gait, reconstruct surgery post https://escuelabiogeometria.com/wp-content/uploads/2022/06/yacjes.pdf
    50e0806aeb hontal

  23. harlwah表示:

    In that case, you can add command line options to the Vim editor for controlling certain features. For example, you can use the eclim-embedded command line to add the ability of compiling modules within Eclipse and exporting the resulting output into compiled Java code files.
    Lastly, if you use eclim-embedded to communicate from the Eclipse to the Eclipse GUI you can take advantage of its ability to integrate against standard operating-system libraries.
    To check out the product, you can https://chronicpadres.com/wp-content/uploads/2022/06/ardiimb.pdf
    50e0806aeb harlwah

  24. ottapad表示:

    How to install GFlagsX in Windows
    Download the latest version from the project’s official website and install the software without any further installation steps.
    You can find the program in the Windows Software Store.
    Supported platforms
    The following platforms are supported by the GFlagsX application:

    However, there is a separate GFlagsX download for Linux, for which there is also a detailed installation guide.

    Interested users will find a.whl file when they download G http://tlcme.org/2022/06/06/reverberate-le-4747-product-key-free-download-march-2022/
    50e0806aeb ottapad

發佈回覆給「acpssszw」的留言 取消回覆

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