WikiCrawler/MediaWiki/WikiUtils.cs
/// <summary>
/// Removes the specified category from the text if it exists.
/// </summary>
Removes the specified category from the text if it exists.
Removes the specified category from the text if it exists .
public static string RemoveCategory(string name, string text)
		{
			if (name.Length <= 0) throw new ArgumentException("Category name cannot be empty.", "name");
			name = name.TrimStart("Category:").TrimStart("category:");
			name = Regex.Escape(name);
			if (char.IsLetter(name[0]))
			{
				name = "[" + char.ToUpper(name[0]).ToString() + char.ToLower(name[0]).ToString() + "]" + name.Substring(1);
			}
			Regex regex = new Regex(@"\[\[[Cc]ategory:" + name + "\\]\\][\r\n]?");
			text = regex.Replace(text, "");
			return text;
		}
public static string RemoveCategory ( string name , string text ) { if ( name . Length <= 0 ) throw new ArgumentException ( " " , " " ) ; name = name . TrimStart ( " " ) . TrimStart ( " " ) ; name = Regex . Escape ( name ) ; if ( char . IsLetter ( name [ 0 ] ) ) { name = " " + char . ToUpper ( name [ 0 ] ) . ToString ( ) + char . ToLower ( name [ 0 ] ) . ToString ( ) + " " + name . Substring ( 1 ) ; } Regex regex = new Regex ( @"\[\[[Cc]ategory:" + name + " \\ \\ \r \n " ) ; text = regex . Replace ( text , " " ) ; return text ; }
Removes the specified category from the text if it exists.
Removes the specified category from the text if it exists .
// if the first character is a letter, it can be upper or lowercase //TODO: whitespace on ends is legal
name
string
text
string