c# - Need to modify my Regex to ignore iframe tags -


hi have free text editor blog posts on website c# code behind. use following regular expression strip html tags out of post security:

regex.replace(value, @"<(.|\n)*?>", string.empty); 

however have requirement allow embedding of youtube videos, use iframe, example:

<iframe width="425" height="349" src="http://www.youtube.com/embed/ttbhgiumumu" frameborder="0" allowfullscreen></iframe> 

could me modify regex allow this?

try one:

<(?!/?iframe)(.|\n)*?> 

the (?!/?iframe) negative lookahead, checks < not followed iframe or /iframe.

i tested online here on regexr


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -