示例#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);
        }
示例#2
0
        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);
        }
示例#3
0
        public static string StripTagsExcludeBr(string inputString)
        {
            var content = RegexUtils.Replace("<[\\/]?br[^>]*>", inputString, "[_LineBreak_]");

            content = StripTags(content);
            content = content.Replace("[_LineBreak_]", "<br />");
            return(content);
        }
示例#4
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);
 }
示例#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);
        }
示例#6
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);
 }
示例#7
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);
        }
示例#8
0
 public static string Censor(string censorRegex, string inputContent)
 {
     return(RegexUtils.Replace(censorRegex, inputContent, "***"));
 }
示例#9
0
 public static string ReplaceBrToNewline(string inputString)
 {
     return(RegexUtils.Replace("<br[^>]*>", inputString, "\n"));
 }
示例#10
0
        public static string StripEntities(string inputString)
        {
            var retval = RegexUtils.Replace("&[^;]*;", inputString, string.Empty);

            return(retval);
        }
示例#11
0
        public static string RemoveAttribute(string content, string attributeName)
        {
            string regex = $@"\s{attributeName}=\""[^\""]*\""";

            return(RegexUtils.Replace(regex, content, string.Empty));
        }