1

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>
Raktim Biswas
  • 4,011
  • 5
  • 27
  • 32
user2598794
  • 697
  • 2
  • 10
  • 23

1 Answers1

2

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>
Community
  • 1
  • 1
Paolo Tedesco
  • 55,237
  • 33
  • 144
  • 193