Wikipedia:Miscellany for deletion/Second batch of mass-created portals based on a single navbox/AWB module

This is the AWB module used as the final step in the list-making for this nomination.

I have not prettified the code. This is how it was when I ran it as part of the list-making described in selection process.

I am an occasional hacker (of 40 years intermittent experience) and not a professional programmer, so the code is crude as hell and as ugly as a very ugly thing. But since it relies on a positive identification, I am confident that any flaws will lead to false negatives, rather than false positives.

It take a portal page, and then:
 * 1) tries to match a call to Transclude list item excerpts as random slideshow or Transclude linked excerpts as random slideshow
 * 2) If not found, skip the page
 * 3) Convert each run of whitespace characters to a single space
 * 4) Strips everything except the parameters
 * 5) Strips up to 7 named parameters
 * 6) Strips up to 3 empty parameters from the end of the string.
 * 7) Checks whether the remaining text is a single parameter beginning
 * 8) If it is NOT a , skip the page

public string ProcessArticle(string ArticleText, string ArticleTitle, int wikiNamespace, out string Summary, out bool Skip) {   Skip = false; Summary = "test";

// string TemplateName = @"(Transclude +list +item +excerpts +as +random +slideshow|Transclude +linked +excerpts +as +random +slideshow)"; Match tsramatch = Regex.Match(ArticleText, @"\{\{(Transclude +list +item +excerpts +as +random +slideshow|Transclude +linked +excerpts +as +random +slideshow)[^\}]*\}\}", RegexOptions.Singleline); if (!tsramatch.Success) { Skip = true; return "no match"; }	 // | paragraphs=1-2 | files=1| Template:Bowerbirds | string tsrcall = Regex.Replace(tsramatch.Value, @"\s+", " ", RegexOptions.Singleline); string tsrstripped = Regex.Replace(tsrcall, @"{{(Transclude +list +item +excerpts +as +random +slideshow|Transclude +linked +excerpts +as +random +slideshow)([^}]*)}}", @"$2", RegexOptions.Singleline); string tsrnoparams = Regex.Replace(tsrstripped, @"\s*\|[^=\|]+=[^=\|]*\|", "|"); tsrnoparams = Regex.Replace(tsrnoparams, @"\s*\|[^=\|]+=[^=\|]*\|", "|"); tsrnoparams = Regex.Replace(tsrnoparams, @"\s*\|[^=\|]+=[^=\|]*\|", "|"); tsrnoparams = Regex.Replace(tsrnoparams, @"\s*\|[^=\|]+=[^=\|]*\|", "|"); tsrnoparams = Regex.Replace(tsrnoparams, @"\s*\|[^=\|]+=[^=\|]*\|", "|"); tsrnoparams = Regex.Replace(tsrnoparams, @"\s*\|[^=\|]+=[^=\|]*\|", "|"); tsrnoparams = Regex.Replace(tsrnoparams, @"\s*\|[^=\|]+=[^=\|]*\|", "|"); tsrnoparams = Regex.Replace(tsrnoparams, @"\s*\|\s*$", ""); tsrnoparams = Regex.Replace(tsrnoparams, @"\s*\|\s*$", ""); tsrnoparams = Regex.Replace(tsrnoparams, @"\s*\|\s*$", ""); Match onetemplate = Regex.Match(tsrnoparams, @"^\s*\|\s*Template:[^\|]+$"); if (!onetemplate.Success) { Skip = true; return "BAD!!!::::\n tsrstripped = [" + tsrstripped + "]\ntsrnoparams = [" + tsrnoparams + "]\n\n" + ArticleText; }	// Success return "Success: only parameter is [" + tsrnoparams + "]"; }