Пример #1
0
        public static string StripTags(string inputString)
        {
            string retval = RegexUtils.Replace("<script[^>]*>.*?<\\/script>", inputString, string.Empty);

            retval = RegexUtils.Replace("<[\\/]?[^>]*>|<[\\S]+", retval, string.Empty);
            return(retval);
        }
Пример #2
0
        public static string StripTagsExcludeBR(string inputString)
        {
            string content = RegexUtils.Replace("<[\\/]?br[^>]*>", inputString, "[_LineBreak_]");

            content = StringUtils.StripTags(content);
            content = content.Replace("[_LineBreak_]", "<br />");
            return(content);
        }
Пример #3
0
        public static string StripTags(string inputString, params string[] tagNames)
        {
            string retval = inputString;

            foreach (string tagName in tagNames)
            {
                retval = RegexUtils.Replace(string.Format("<[\\/]?{0}[^>]*>|<{0}", tagName), retval, string.Empty);
            }
            return(retval);
        }
Пример #4
0
        public static string Replace(string replace, string input, string to)
        {
            string retval = RegexUtils.Replace(replace, input, to);

            if (!string.IsNullOrEmpty(replace))
            {
                if (replace.StartsWith("/") && replace.EndsWith("/"))
                {
                    retval = RegexUtils.Replace(replace.Trim(new char[] { '/' }), input, to);
                }
                else
                {
                    retval = input.Replace(replace, to);
                }
            }
            return(retval);
        }
Пример #5
0
 public static string Censor(string censorRegex, string inputContent)
 {
     return(RegexUtils.Replace(censorRegex, inputContent, "***"));
 }
Пример #6
0
 public static string ReplaceBRToNewline(string inputString)
 {
     return(RegexUtils.Replace("<br[^>]*>", inputString, "\n"));
 }
Пример #7
0
        public static string StripEntities(string inputString)
        {
            string retval = RegexUtils.Replace("&[^;]*;", inputString, string.Empty);

            return(retval);
        }
Пример #8
0
        public static string RemoveAttribute(string content, string attributeName)
        {
            string regex = string.Format(@"\s{0}=\""[^\""]*\""", attributeName);

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