Exemplo n.º 1
0
        public static string StripTags(string inputString)
        {
            var retval = RegexUtils.Replace("<script[^>]*>.*?<\\/script>", inputString, string.Empty);

            retval = RegexUtils.Replace("<[\\/]?[^>]*>|<[\\S]+", retval, string.Empty);
            return(retval);
        }
Exemplo n.º 2
0
        public static string StripTagsExcludeBr(string inputString)
        {
            var content = RegexUtils.Replace("<[\\/]?br[^>]*>", inputString, "[_LineBreak_]");

            content = StripTags(content);
            content = content.Replace("[_LineBreak_]", "<br />");
            return(content);
        }
Exemplo n.º 3
0
 public static string ClearFontSize(string html)
 {
     if (string.IsNullOrEmpty(html))
     {
         return(string.Empty);
     }
     html = RegexUtils.Replace(@"font-size:\w+;", html, string.Empty);
     return(html);
 }
Exemplo n.º 4
0
 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);
 }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
 public static string ReplaceBrToNewline(string inputString)
 {
     return(RegexUtils.Replace("<br[^>]*>", inputString, "\n"));
 }
Exemplo n.º 8
0
        public static string StripEntities(string inputString)
        {
            var retval = RegexUtils.Replace("&[^;]*;", inputString, string.Empty);

            return(retval);
        }
Exemplo n.º 9
0
        public static string RemoveAttribute(string content, string attributeName)
        {
            string regex = $@"\s{attributeName}=\""[^\""]*\""";

            return(RegexUtils.Replace(regex, content, string.Empty));
        }
Exemplo n.º 10
0
 public static string Censor(string censorRegex, string inputContent)
 {
     return(RegexUtils.Replace(censorRegex, inputContent, "***"));
 }