Assets/Watson/Scripts/Utilities/Utility.cs
/// <summary>
/// Removes any tags from a string. (e.g. <title></title>)
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
Removes any tags from a string.
Removes any tags from a string .
public static string RemoveTags(string s, char tagStartChar = '<', char tagEndChar = '>' )
        {
            if (!string.IsNullOrEmpty(s))
            {
                int tagStart = s.IndexOf(tagStartChar);
                while (tagStart >= 0)
                {
                    int tagEnd = s.IndexOf(tagEndChar, tagStart);
                    if (tagEnd < 0)
                        break;
                    string pre = tagStart > 0 ? s.Substring(0, tagStart) : string.Empty;
                    string post = tagEnd < s.Length ? s.Substring(tagEnd + 1) : string.Empty;
                    s = pre + post;
                    tagStart = s.IndexOf(tagStartChar);
                }
            }
            return s;
        }
public static string RemoveTags ( string s , char tagStartChar = ' ' , char tagEndChar = ' ' ) { if ( ! string . IsNullOrEmpty ( s ) ) { int tagStart = s . IndexOf ( tagStartChar ) ; while ( tagStart >= 0 ) { int tagEnd = s . IndexOf ( tagEndChar , tagStart ) ; if ( tagEnd < 0 ) break ; string pre = tagStart > 0 ? s . Substring ( 0 , tagStart ) : string . Empty ; string post = tagEnd < s . Length ? s . Substring ( tagEnd + 1 ) : string . Empty ; s = pre + post ; tagStart = s . IndexOf ( tagStartChar ) ; } } return s ; }
Removes any tags from a string.
Removes any tags from a string .
None
s
string
None
tagStartChar
char
tagEndChar
char