Meghana M

Meghana M

  • 1.2k
  • 175
  • 19.2k

Replacing tags with another tag in the text using C# console applicati

Dec 15 2023 7:49 AM

1) multiple &nbsp tag ,<p style="text-align:start"> tag should be replaced with blank space 

2)<h1>...<h6> tag should be replaced with strong tag

3) <ol start="4">$,<ol start="NaN"> tag should be replaced with "$" for ordered list and " | " for unordered list

I need to add extra tags and replace with above-mentioned tags with the existing below code :

  if (!string.IsNullOrEmpty(Value))
                            {
                                if (Value.Contains("<ul>"))
                                {
                                    Value = Value.Replace("<li>", "|").Replace("<ul>", "").Replace("</ul>", "");
                                }
                                if (Value.Contains("<ol>"))
                                {
                                    Value = Value.Replace("<li>", "$").Replace("<ol>", "").Replace("</ol>", "");
                                }

                                Value = Value.Replace("</li>", "").Replace("<p>", "").Replace("</p>", "");

                            }

}


Answers (1)