Remove particular HTML Tag for a string
Hi Guy's,
Suppose we have a string like this :
<p>
<span>Learn to use Excel to identify what happened in the past,</span> so you can better prepare for the future. <bold>By using Excel as a trend analysis tool</bold>, CFOs, controllers and financial analysts will be able to use the data from budgets and financial statements to work through the planning and forecasting process.
</p>.
And we want to remove <bold> Tag from the above string then what to Do ?
We can use Below method to archive this :
public static string removeSingleTagFromText(string text, string tagName)
{
string x = "<" + tagName + @"\b[^>]*>(.*?)</" + tagName + ">";
Regex m = new Regex(@"<p\b[^>]*>(.*?)</p>", RegexOptions.IgnoreCase | RegexOptions.Multiline);
return m.Replace(text, "");
}
Suppose we have a string like this :
<p>
<span>Learn to use Excel to identify what happened in the past,</span> so you can better prepare for the future. <bold>By using Excel as a trend analysis tool</bold>, CFOs, controllers and financial analysts will be able to use the data from budgets and financial statements to work through the planning and forecasting process.
</p>.
And we want to remove <bold> Tag from the above string then what to Do ?
We can use Below method to archive this :
public static string removeSingleTagFromText(string text, string tagName)
{
string x = "<" + tagName + @"\b[^>]*>(.*?)</" + tagName + ">";
Regex m = new Regex(@"<p\b[^>]*>(.*?)</p>", RegexOptions.IgnoreCase | RegexOptions.Multiline);
return m.Replace(text, "");
}
Comments
Post a Comment