Marco C
Marco C

Reputation: 3213

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?

Upvotes: 0

Views: 993

Answers (1)

aaronman
aaronman

Reputation: 18750

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

Upvotes: 2

Related Questions