Argentini.Halide.H3Text.StripSpecificTag C# (CSharp) Method

StripSpecificTag() public static method

Return the current string with all instances of a specific tag removed.
public static StripSpecificTag ( string strVar, string tagName ) : String
strVar string String to process.
tagName string Tag name to strip (e.g. blockquote)
return String
        public static String StripSpecificTag(string strVar, string tagName)
        {
            string retVal = strVar;

            retVal = SanitizeEscapes(retVal);

            if (FixNull(strVar) == string.Empty)
            {
                return (strVar);
            }
            else
            {
                //Regex tags = new Regex(@"<.*?" + tagName + ".*?>.*?<.*?/.*?" + tagName + ".*?>", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace | RegexOptions.Singleline);
                //retVal = tags.Replace(retVal, "");

                Regex tags = new Regex(@"<[\s]*" + tagName + @".*?>", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace | RegexOptions.Singleline);
                retVal = tags.Replace(retVal, "");

                tags = new Regex(@"<[\s]*/[\s]*?" + tagName + @".*?>", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace | RegexOptions.Singleline);
                retVal = tags.Replace(retVal, "");

                return retVal;
            }
        }