How can I manipulate this code to run multiple Regex.Replaces on the same string?
public static class StringExtensions
{
public static string SkipImgTags(this string html, int length)
{
string strReplaceHtml = Regex.Replace(html, @"(< *?/*)strong( +?|>)", @"(< *?/*)bold( +?|>)", RegexOptions.IgnoreCase);
return strReplaceHtml;
}
}
I attempted to stack the following but was unsuccessful:
string strReplaceHtml = Regex.Replace(html, @"(< *?/*)strong( +?|>)", @"(< *?/*)bold( +?|>)", RegexOptions.IgnoreCase);
string strReplaceHtml = Regex.Replace(html, @"(< *?/*)em( +?|>)", @"(< *?/*)italic( +?|>)", RegexOptions.IgnoreCase);
I think you are close. Consider the following minor change to your code...
string strReplaceHtml = Regex.Replace(html, @"(< *?/*)strong( +?|>)", @"(< *?/*)bold( +?|>)", RegexOptions.IgnoreCase);
strReplaceHtml = Regex.Replace(strReplaceHtml , @"(< *?/*)em( +?|>)", @"(< *?/*)italic( +?|>)", RegexOptions.IgnoreCase);
Good Luck!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.