简体   繁体   中英

Extract CSS Style From String in JAVA

I have a string in Java not escaped which contains CSS, JavaScript and HTML.

I need to extract all the CSS from this string, so basically I need to search for everything that start for <style and finish for </style> and everything that start for <link and finish for >

Any suggestions?

The regex might look something like this. String result = searchText.replaceAll("<style>([^<]*)</style>", "$1"); this should change the text to whats inside the tag, just modify it slightly for the tag

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM