How to adjust regex point to match strings?

I am trying to figure this out:

<STYLE> lots of text and linebreaks </STYLE> 

How can I detect ANYTHING inside a style tag (including lines)? I have tried.*? but did not help

THX

+4
source share
3 answers

.* does not work with your sample text because . does not match new lines. You can enable single-line mode in your regular expression implementation (some of them do not support it, for example javascript), or you can use [\S\s]* instead of .* [\S\s]* .

+3
source

you probably need to add the "s" modifier to regexp. Without the s, the dot does not match newlines.

remember, however, that regexp is the wrong tool for html parsing, better consider the dedicated parsing library available in your language.

+2
source

Regex is a poor way to parse HTML. Jeff Atwood is a good article on it.

+1
source

All Articles