Reputation: 727
How could I match a text between a span opening and closing tags with style attribute?:
<span style="white-space: pre-line">some text</span>
I tried the following pattern but it doesn't work:
<span style=\"white-space: pre-line\">(.*)</span>
Upvotes: 1
Views: 1399
Reputation: 57302
First of all, it is in general a bad idea to parse HTML with a Regex.
It would be better to use a solution to parse HTML, like HTML Agility Pack.
That said, if you need help with Regular Expressions, you can download a tool that will help you analyze and test them. There are several tools available for that, I personally like Expresso.
In this particular case, I think you are having problems with the spaces, but I cannot be sure since you are not showing the RegexOptions you are using to build your Regex. Try
<span\s*style=\"white-space:\s*pre-line\">(.*)</span>
Upvotes: 2