public static string StripTags(string inputString) { var retval = RegexUtils.Replace("<script[^>]*>.*?<\\/script>", inputString, string.Empty); retval = RegexUtils.Replace("<[\\/]?[^>]*>|<[\\S]+", retval, string.Empty); return(retval); }
private static string ParseReplace(string parsedContent, string replace, string to) { if (replace.IndexOf(',') != -1) { var replaceList = TranslateUtils.StringCollectionToStringList(replace); var toList = TranslateUtils.StringCollectionToStringList(to); if (replaceList.Count == toList.Count) { for (var i = 0; i < replaceList.Count; i++) { parsedContent = parsedContent.Replace(replaceList[i], toList[i]); } return(parsedContent); } } string retval; if (replace.StartsWith("/") && replace.EndsWith("/")) { retval = RegexUtils.Replace(replace.Trim('/'), parsedContent, to); } else { retval = parsedContent.Replace(replace, to); } return(retval); }
public static string StripTagsExcludeBr(string inputString) { var content = RegexUtils.Replace("<[\\/]?br[^>]*>", inputString, "[_LineBreak_]"); content = StripTags(content); content = content.Replace("[_LineBreak_]", "<br />"); return(content); }
public static string ClearFontSize(string html) { if (string.IsNullOrEmpty(html)) { return(string.Empty); } html = RegexUtils.Replace(@"font-size:\w+;", html, string.Empty); return(html); }
public static string StripTags(string inputString, params string[] tagNames) { var retval = inputString; foreach (var tagName in tagNames) { retval = RegexUtils.Replace($"<[\\/]?{tagName}[^>]*>|<{tagName}", retval, string.Empty); } return(retval); }
public static string ClearFontFamily(string html) { if (string.IsNullOrEmpty(html)) { return(string.Empty); } html = RegexUtils.Replace(@"font-family:'\w+';", html, string.Empty); html = RegexUtils.Replace(@"font-family:\w+;", html, string.Empty); return(html); }
public static string Replace(string replace, string input, string to) { var retval = RegexUtils.Replace(replace, input, to); if (string.IsNullOrEmpty(replace)) { return(retval); } if (replace.StartsWith("/") && replace.EndsWith("/")) { retval = RegexUtils.Replace(replace.Trim('/'), input, to); } else { retval = input.Replace(replace, to); } return(retval); }
public static string Censor(string censorRegex, string inputContent) { return(RegexUtils.Replace(censorRegex, inputContent, "***")); }
public static string ReplaceBrToNewline(string inputString) { return(RegexUtils.Replace("<br[^>]*>", inputString, "\n")); }
public static string StripEntities(string inputString) { var retval = RegexUtils.Replace("&[^;]*;", inputString, string.Empty); return(retval); }
public static string RemoveAttribute(string content, string attributeName) { string regex = $@"\s{attributeName}=\""[^\""]*\"""; return(RegexUtils.Replace(regex, content, string.Empty)); }