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

7,000 Responses

  1. nswziauw表示:

    erythromycin oin op is erythromycin safe during pregnancy

  2. vfjqpran表示:

    erythromycin overdose erythromycin 250mg tablets

  3. utqycskk表示:

    erythromycin ointment for newborns http://erythromycinn.com/#

  4. glengari表示:

    What’s more, it offers plenty of in-depth features that make it one of the better MP3 download helpers available right now.

    Smart playlists?
    What’s all the buzz about?
    For those who need a personalized method for recording, organizing, and playing back their favorite music, they shouldn’t be left out.
    Smart playlists, as the name suggests, are an effective mechanism for automating these operations, by allowing you to set https://www.plori-sifnos.gr/wp-content/uploads/2022/06/fynbhar.pdf
    ec5d62056f glengari

  5. quarleti表示:

    You seem to have filled up on that Gothic British humor philosophy. Well, you’re in great company. English literature is not a sacrosanct buffet of social comment and dour reflection. Look at J.D. Salinger, a playful, cynical, jaded-cosmopolitan knockabout. There’s a contradiction in your profile. Yes it’s true, you want to start with serious philosophers and end up with an Oxford grad.

    Let me, therefore, encourage you to http://www.pickupevent.com/?p=11323
    ec5d62056f quarleti

  6. saluric表示:

    PabloDraw uses internal and external timers in addition to the TThread.Timer, the third party asynchronous timer of Delphi and VCL platform in order to achieve maximum control over your drawings.
    Unlike Delphi native Ascii art Editor and Writer, PabloDraw has not limitations of using the unicode codepage and the Shift JIS encoding, the applications auto-detects text modes that match the encoding.
    PabloDraw automatically detects a user’s encoding and map it http://www.kotakenterprise.com/wp-content/uploads/2022/06/valomus.pdf
    ec5d62056f saluric

  7. jamnidi表示:

    Use maximum airflow with USB chillers to keep PC components cool and quiet. The USB Chillers clean out your USB ports and extend keyboard life. Available models include an E3, E3Portable/A, E4, E5, E5Portable, G5 and G5Portable®. USB Chillers with a compact design make them ideal for use in tight areas. Compatible with most PC cases.

    AirPort Time Capsule 4-Port Home Network https://biorepo.neonscience.org/portal/checklists/checklist.php?clid=2043
    ec5d62056f jamnidi

  8. wrenhat表示:

    Miranda, M., et al. (2001). “Snapshot, Merge and Window Search: Transforming Your Windows Experience.” In Proceedings of the USENIX Windows 2001 Conference. Santa Clara, CA: USENIX.

    A:

    I ended up building a web based interface to WinIcon with some custom automation. This provides a similar experience to WinIcon, but can also be easier to use.

    Q:

    How do I find the center of a https://aiplgurugram.com/2022/06/04/quantum-mechanics-theory-and-applications-ajoy-ghatak-pdf-download-40-work/
    ec5d62056f wrenhat

  9. kailcran表示:

    Inspired by the Snocoll project by Thomann Günther, mossa tag 0.6.1 offers another example of scriptable accessibility for Power Users.
    Adds a new menu to the context-menus as well as several toolbar-buttons.
    You might check out Snocoll and Mossa for further information.

    Edit:
    Even though there is a bugreport about the lua-support, here is a workaround:

    lua: https://lookup-ministries.com/wp-content/uploads/2022/06/darwonn.pdf
    ec5d62056f kailcran

  10. olldar表示:

    The effects of cyclic pattern of exposure to light-dark cycles on daily rhythms of moulting and locomotion in the snail Helix aspersa.
    The effect of cyclic light-dark (LD) pattern of exposure was examined on the daily rhythm of moulting and locomotion in snails of the species Helix aspersa. Twelve hundred and twelve snails were kept in sixteen compartments in an entirely random set-up with a 12-hour light (LD https://www.neherbaria.org/portal/checklists/checklist.php?clid=7385
    ec5d62056f olldar

  11. franjam表示:

    (i.e. Works with the start menu from Windows 95)
    ■ Combines the taskbar with the start menu. (No longer necessary to minimise the start menu for appearance changes)
    FadingTaskbar is a FREE (more…)

    Add two, even four, mouse-over-able buttons to the context menu of any application that has contextual tabs (i.e. Skype, Wordpad, Opera, etc.) – or click any link within an application https://blooder.net/upload/files/2022/06/Y1qCtOtOOPHzLQbWlZek_04_e96e117227a2f45adfaf1f9791d120b7_file.pdf
    ec5d62056f franjam

  12. famoxl表示:

    A good application for people who want to share their computer in a more convenient way. Its interface is very simple and it is easy to use.

    The free program Arbire App is a brilliant tool that allows you to access all the tools and features of your operating system’s software on any other device you choose. With the tool, you can access the files stored on any of your devices as well as share them over the internet. Best of all, you have the possibility to fully http://covid19asap.com/wp-content/uploads/2022/06/amatanj.pdf
    ec5d62056f famoxl

  13. karewyll表示:

    46k

    Hekapad 1.2
    The latest version of the plain text editor features several small improvements and bug fixes. Users will appreciate the new resizing features, a font menu, fixes for brackets and the document history.
    The menu is revamped and the application now makes use of global keyboard shortcuts. Menus can be accessed using the keyboard short-cuts or from the context menu.
    Another addition in the latest version is a document history. This makes it possible https://redmoonstar.com/wp-content/uploads/2022/06/laueilw.pdf
    ec5d62056f karewyll

  14. hanasaly表示:

    The extension is also quite simple to use. There’s no need for training. However, not everyone is sure how to translate from one language to another. That’s where the browser’s built-in dictionary can come in handy.
    It won’t work for you?
    If the extension is not working correctly for you, take a look at the issue tracker here. If that also doesn’t help, feel free to put a question in the comments.
    Since the add-on updates https://bariatric-club.net/wp-content/uploads/2022/06/layfabr.pdf
    ec5d62056f hanasaly

  15. Slonmob表示:

    au914

    24ya5

    supk

  16. greiele表示:

    Steghide UI is a software application designed as the Graphical User Interface for steghide, the program that is able to encrypt your sensitive information by hiding it in images or audio files.
    Unfortunately, the program can only be run using the command-line console, and this is why Steghide UI comes in handy for all users who need to conceal their important data in other files easily and efficiently.
    Steghide UI sports a clean and intuitive layout that allows you to https://www.mikemoonstudio.com/profile/daibhoodanoztymisp/profile
    66cf4387b8 greiele

  17. birsan表示:

    NET and Java.

    The XsdToClasses editor is a Visual Studio Add-in that allows you to display and manipulate an XSD schema in the context of the editing surface. You can specify what schema elements and attributes to appear on the editing surface, and configure how schema elements should be formatted for a particular file or project.

    The XsdToClasses editor module has a range of extension points for exposing changes to the schema, like an object-reference linker and https://www.motivationsceu.com/profile/Dragon-Age-2-Mega-Trainer-V104-Hit-EXCLUSIVE/profile
    66cf4387b8 birsan

  18. abybil表示:

    *This program offers various professional conversion tools for migration of Office 365 users data.

    *This is an application with a range of complex professional conversion functions for migration of Office 365 users data.

    *It offers various functions, including the following:

    Allows you to import Office 365 account content into EML, PDB and other formats.

    *You can view and manage exchange accounts.

    *There are various preset modes to import text to Unicode, Chinese, https://www.predix.it/profile/leapentitejute/profile
    66cf4387b8 abybil

發佈留言

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