How to remove image source from html content?


Here is my code, I wanna remove image source from HTML content. 

Please provide some solution to achieve this task.

 <div class="col-md-12">

Last updated:3/12/2018 11:23:11 PM

1 Answers

Harsh kumar srivastava
Harsh kumar srivastava

Hi Ethan,

Follow these steps to achieve your task.

Step 1. Write below a line of code at top of the page.

    string regexImgSrc = @'<img[^>]*?src\s*=\s*[''']?([^''' >]+?)[ '''][^>]*?>'; }

Step 2. And modify your code as follows.

<div class='col-md-12'>
    @Html.Raw(System.Text.RegularExpressions.Regex.Replace(item.Content, regexImgSrc, ''))

Hope it's helpful !!!