How to remove image source from html content?

Total Post:4

Points:28
 294  View(s)
Ratings:
Rate this:

Hi,

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">

    @Html.Raw(item.Content)
 </div>
  1. Post:44

    Points:310
    Re: How to remove image source from html content?

    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, ""))
    </div>

    Hope it's helpful !!!


      Modified On Mar-12-2018 11:27:11 PM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!