Skip Image from Content using Regex

Total Post:1

Points:7
C#  Mvc 
C#
 292  View(s)
Ratings:
Rate this:

I want to skip image from content ..this is my sample code please help

@{

    string regexImgSrc = @"<img[^>]*?src\s*=\s*[""']?([^'"" >]+?)[ '""][^>]*?>";
}
 @if (post.Content.Length > 70)
       {
              var str = post.Content.Substring(0, 70);

           }
  1. Post:1

    Points:7
    Re: Skip Image from Content using Regex

    try this code this will helps you

    @{
    
       string regexImgSrc = @"<img[^>]*?src\s*=\s*[""']?([^'"" >]+?)[ '""][^>]*?>";
    }
     @if (post.Content.Length > 70)
                    {
                      var str = post.Content.Substring(0, 70);
     @Html.Raw(System.Text.RegularExpressions.Regex.Replace(str.ToString(), regexImgSrc, ""))
                                                          
                  }

Answer