Home > Net >  How can I use a regex to match HTML inline style attributes with "display:none"?
How can I use a regex to match HTML inline style attributes with "display:none"?

Time:02-15

I'm trying to get the tag HTML in a single regex expression when I have a specific style style='display:none' and keep the content inside.

The current regex that I'm using:

(<span\sstyle=[\"\'] display[:=]none[\"\'\;] >)|(<\/span>)

Result:

enter image description here

I'm getting a close </span> when it's not supposed in the line 2 and 4. Demo

CodePudding user response:

Try this

(<span\sstyle=[\"\'] display[:=]none[\"\'\;] >)(?:[\w\s] )(<\/span>)
  • Related