Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

enter image description here

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

>Solution :

Try this

(<span\sstyle=[\"\']+display[:=]none[\"\'\;]+>)(?:[\w\s]+)(<\/span>)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading