Jump to content

User:Dawnseeker2000/MDY module

From Wikipedia, the free encyclopedia
//all dates to mdy
// <syntaxhighlight lang="CSharp">
        WikiFunctions.Parse.HideText ht = new WikiFunctions.Parse.HideText(true, false, true);

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

ArticleText = ht.Hide(ArticleText);

////User:Ohconfucius/AWB modules/dmy
//protect dates
 ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[September)( 11 attacks\|)", "$1♫$2");
 ArticleText=Regex.Replace(ArticleText, @"(?i)(100\s)(crore club\D)", "$1♫$2");
// ArticleText=Regex.Replace(ArticleText, @"(?i)(september\s)(11\D)", "$1♫$2");

//fix common errors
//rem superscripted ordinals
 ArticleText=Regex.Replace(ArticleText, @"(?i)(\d)<sup>(th|st|nd|rd)<\/sup>", "$1$2");

 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[([12]?\d|30|31)(?:th|st|nd|rd|)(?:_|&nbsp;)(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)", "[[$1 $2");
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)(?:_|&nbsp;)([12]?\d|30|31)(?:th|st|nd|rd|)", "[[$1 $2");

//month+day piped to month+day
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:[12]?\d|30|31)(?:th|st|nd|rd|)\s(?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\|(\d{1,2}\s)(?:th|st|nd|rd|)(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\]\]", "[[$1$2]]");
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\s(?:[12]?\d|30|31)(?:th|st|nd|rd|)\|(\d{1,2}\s)(?:th|st|nd|rd|)(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\]\]", "[[$1$2]]");
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[\d{1,2}\s(?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\|(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)(\s\d{1,2})(?:th|st|nd|rd|)\]\]", "[[$1$2]]");
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\s(?:[12]?\d|30|31)(?:th|st|nd|rd|)\|(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)(\s\d{1,2})(?:th|st|nd|rd|)\]\]", "[[$1$2]]");

//month+day piped to number
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:[12]?\d|30|31)(?:th|st|nd|rd|)\s(?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\|(\d{1,4})\]\]", "[[$1]]");
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\s(?:[12]?\d|30|31)(?:th|st|nd|rd|)\|(\d{1,4})\]\]", "[[$1]]");

//part dates

//remove leading zeros from dts templates
 ArticleText=Regex.Replace(ArticleText, @"(?i)({{dts\d?\|[^}]*\|)0([^}]*}})", "$1$2");

//delink ISO dates
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[([12]\d{3}-\d\d-\d\d)\]\]", "$1");
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[([12]\d{3})\]\]-\[\[(\d\d-\d\d)\]\]", "$1-$2");
 ArticleText=Regex.Replace(ArticleText, @"(?i)([12]\d{3})-\[\[(\d\d-\d\d)\]\]", "$1-$2");
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[([12]\d{3})\]\]-(\d\d-\d\d)", "$1-$2");

//remove year in xxxx
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:1[7-9]|20)\d{2}\sin\s[^\|\]]+\|(\d{4})\]\]", "$1");

//remove dts1 template that links ISO dates
 ArticleText=Regex.Replace(ArticleText, @"(?i)\{\{dts1\|(\d{4}-\d\d-\d\d)\}\}", "$1");

// century
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[((?:first|second|third|fourth|fifth|sixth|seventh|eighth|ninth|tenth|eleventh|twelfth|thirteenth|fourteenth|fifteenth|sixteenth|seventeenth|eighteenth|nineteenth|twentieth|twenty(?:\s|-)first)(?:\s|-))century\]\]", "$1century");
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[((?:first|second|third|fourth|fifth|sixth|seventh|eighth|ninth|tenth|eleventh|twelfth|thirteenth|fourteenth|fifteenth|sixteenth|seventeenth|eighteenth|nineteenth|twentieth|twenty(?:\s|-)first)(?:\s|-))century\s(AD|BC|CE|BCE)\]\]", "$1century");
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(\d{1,2}(?:st|nd|rd|th)(?:\s|-))century\]\]", "$1century");
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(\d{1,2}(?:st|nd|rd|th)(?:\s|-))centuries\]\]", "$1centuries");
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[\d{1,2}(?:st|nd|rd|th)(?:\s|-)century\|(\d{1,2}(?:st|nd|rd|th))\]\]", "$1");
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[\d{1,2}(?:st|nd|rd|th)(?:\s|-)century\|(\d{1,2}(?:st|nd|rd|th)(?:\s|-))century\]\]", "$1century");
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[\d{1,2}(?:st|nd|rd|th)(?:\s|-)century\|(\d{1,2}(?:st|nd|rd|th)(?:\s|-))centuries\]\]", "$1centuries");
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(\d{1,2}(?:st|nd|rd|th)(?:\s|-))century\s(AD|BC|CE|BCE)\]\]", "$1century $2");
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[\d{1,2}(?:st|nd|rd|th)(?:\s|-)century\|(\d{1,2}(?:st|nd|rd|th)(?:\s|-))century\s(AD|BC|CE|BCE)\]\]", "$1century $2");
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[\d{1,2}(?:st|nd|rd|th)(?:\s|-)century\|(\d{1,2}(?:st|nd|rd|th)(?:\s|-))centuries\s(AD|BC|CE|BCE)\]\]", "$1centuries $2");

// decades and years
 ArticleText=Regex.Replace(ArticleText, @"\[\[(\d{1,3}0)\'?s\]\]", "$1s");
 ArticleText=Regex.Replace(ArticleText, @"\[\[\d{1,3}0\'?s\|([^\]]{1,30})\]\]", "$1");
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(\d{1,3}0)\'?(s)?[\s_]?(AD|BC|CE|BCE)\]\]", "$1$2 $3");
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[\d{1,3}0\'?s?[\s_]?(?:AD|BC|CE|BCE)\|([^\]]{1,30})\]\]", "$1");
//year: now remove unprotected linked years
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[((?:1[0-9]|20)\d{2}|[1-9]\d{0,2})([\s_]?(?:AD|BC|CE|BCE)|)\]\]", "$1$2");
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[\d{1,3}0\'?s?[\s_]?\(decade\)\|([^\]]{1,30})\]\]", "$1");
 ArticleText=Regex.Replace(ArticleText, @"(\d{1,3}0)\'?s", "$1s");

// solitary day_numbers
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d{1,2}(?:th|st|nd|rd)\|(\d{1,2})(?:th|st|nd|rd)\]\]", "$1");
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[\d{1,2}(?:th|st|nd|rd)\s(?:January|February|March|April|May|June|July|August|September|October|November|December)\|(\d{1,2})(?:th|st|nd|rd)\]\]", "$1");
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(\d{1,2}(?:st|nd|rd|th))\]\]", "$1");

//month+year
//Identify surprise or 'Easter egg' diversions linking month+years to year articles. Turn them into month+year links to be dealt with below
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[\d{1,4}#[^\|\]]+\|((?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d{3,4})\]\]", "[[$1]]");
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d{3,4})\]\]", "$1");
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.?|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s\d{3,4}\|([^\]]{1,30})\]\]", "$1");

//removed piped years when in full date
 ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[\d{1,2}\s(?:January|February|March|April|May|June|July|August|September|October|November|December)\]\],?\s?\[\[)[^\|\]]{1,32}\|(\d{1,4}\]\])", "$1$2");
 ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d{1,2}\]\],?\s?\[\[)[^\|\]]{1,32}\|(\d{1,4}\]\])", "$1$2");

//remove piped years
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:19\d|20[01])\d in (?:aviation|baseball|film|literature|comics|ireland|india)\|((?:19|20)\d{2})\]\]", "$1");

//Identify surprise or 'Easter egg' diversions linking months to year articles.
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[\d{1,4}#[^\|\]]+\|(January|February|March|April|May|June|July|August|September|October|November|December)\]\]", "$1");

//Month+day_number "March 7th" -> "March 7"
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s(\d?\d)(?:th|st|nd|rd)\]\]", "[[$1 $2]]");
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[((?:Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s\d?\d)\]\](?:th|st|nd|rd)", "[[$1]]");
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(\d?\d)(?:th|st|nd|rd)\s(January|February|March|April|May|June|July|August|September|October|November|December)\]\]", "$1 $2");

//Remove nbsp within date strings
 ArticleText=Regex.Replace(ArticleText, @"(?i)(\D\d{1,3})(th|st|nd|rd)&nbsp;(?=\w)", "$1$2 ");
 ArticleText=Regex.Replace(ArticleText, @"(?i)(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))&nbsp;(\d?\d(?:th|st|nd|rd|)\D)", "$1 $2");
 ArticleText=Regex.Replace(ArticleText, @"(?i)(\D\d?\d)(?:th|st|nd|rd|)&nbsp;(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))(?=\W)", "$1 $2");
 ArticleText=Regex.Replace(ArticleText, @"(?i)(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s*&nbsp;\s*((?:19\d|20[01])\d)(?=\D)", "$1 $2");
//(month yyyy-month yy)
 ArticleText=Regex.Replace(ArticleText, @"(?i)\((Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.?|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s(20)([01]\d)\s?[-–]\s?(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.?|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s([01]\d)\)", "($1 $2$3–$4 $2$5)");
 ArticleText=Regex.Replace(ArticleText, @"(?i)\((Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.?|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s(19)([3-9]\d)\s?[-–]\s?(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.?|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s([3-9]\d)\)", "($1 $2$3–$4 $2$5)");
 ArticleText=Regex.Replace(ArticleText, @"(?i)\((Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.?|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s(19)(9\d)\s?[-–]\s?(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.?|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s([01]\d)\)", "($1 $2$3–$4 20$5)");

 ArticleText=Regex.Replace(ArticleText, @"(?:the\s?|)([1-2]?\d|30|31)(?:th|st|nd|rd|), ([1-2]?\d|30|31)(?:th|st|nd|rd|)(\s(?:and|&|to|or)\s[1-3]?\d)(?:th|st|nd|rd|)(?:\sof\s?)?\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))(?=\W)", "$1, $2$3 $4");
 ArticleText=Regex.Replace(ArticleText, @"(?:the\s?|)([1-2]?\d|30|31)(?:th|st|nd|rd|)(\s(?:and|&|to|or)\s|[-–])([1-3]?\d)(?:th|st|nd|rd|)(?:\sof\s?)?\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))(?=\W)", "$1$2$3 $4");
 ArticleText=Regex.Replace(ArticleText, @"(?:the\s?|)([1-2]?\d|30|31)(?:th|st|nd|rd|)(?:\sof\s?)\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))(?=[^\|\]\w\d])", "$1 $2");
 ArticleText=Regex.Replace(ArticleText, @"(?:the\s?|)([1-2]?\d|30|31)(?:th|st|nd|rd|)(?:\sof\s?)?\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))(?=\W)", "$1 $2");
 ArticleText=Regex.Replace(ArticleText, @"(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s(?:the\s|)([1-2]?\d|30|31)(?:th|st|nd|rd|),\s(?:the\s|)([1-2]?\d|30|31)(?:th|st|nd|rd|)(\s(?:and|&|to|or)\s)(?:the\s|)([1-2]?\d|30|31)(?:th|st|nd|rd|)(?=[^\]\|\w\d]\D)", "$1 $2, $3$4 $5");
 ArticleText=Regex.Replace(ArticleText, @"(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s(?:the\s|)([1-2]?\d|30|31)(?:th|st|nd|rd|)(\s(?:and|&|to|or)\s)(?:the\s|)([1-2]?\d|30|31)(?:th|st|nd|rd|)(?=[^\]\|\w\d]\D)", "$1 $2$3$4");
 ArticleText=Regex.Replace(ArticleText, @"(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s(?:the\s|)([1-3]?\d)(?:th|st|nd|rd)(?=[^\]\|\w\d]\D)", "$1 $2");

 ArticleText=Regex.Replace(ArticleText, @"(\s*=\s*)((?:19|20)\d\d)\s+(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s([1-3]?\d)(?=[\s\r\n]*[\|\}])", "$1$4 $3 $2");
 ArticleText=Regex.Replace(ArticleText, @"(\s*\()((?:19|20)\d\d)\s+(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s([1-3]?\d)(?=\))", "$1$4 $3 $2");

//Month+day_number piped into number. Preferences do not work. They don't work in sequence because digits in the two dates must be adjacent
 ArticleText=Regex.Replace(ArticleText, @"(?i)([^\[]{4})\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d?\d)\]\](\s?\-?\s?)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d{1,2}(?:th|st|nd|rd)\|(\d{1,2}(?:th|st|nd|rd))\]\]", "$1$2$3$4");
//same again but with ndash or mdash instead of hyphen
 ArticleText=Regex.Replace(ArticleText, @"(?i)([^\[]{4})\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d?\d)\]\](\s?&[nm]dash;\s?)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d{1,2}(?:th|st|nd|rd)\|(\d{1,2}(?:th|st|nd|rd))\]\]", "$1$2$3$4");
//same again but with slash instead of hyphen
 ArticleText=Regex.Replace(ArticleText, @"(?i)([^\[]{4})\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d?\d)\]\](\/)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d{1,2}(?:th|st|nd|rd)\|(\d{1,2}(?:th|st|nd|rd))\]\]", "$1$2$3$4");

 ArticleText=Regex.Replace(ArticleText, @"(?i)([^\[]{4})\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d?\d)\]\](\s?\-?\s?)\[\[(\d{1,2}(?:th|st|nd|rd))\]\]", "$1$2$3$4");
//same again but with ndash instead of hyphen
 ArticleText=Regex.Replace(ArticleText, @"(?i)([^\[]{4})\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d?\d)\]\](\s?&[nm]dash;\s?)\[\[(\d{1,2})\]\]", "$1$2$3$4");
//same again but with slash instead of hyphen
 ArticleText=Regex.Replace(ArticleText, @"(?i)([^\[]{4})\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d?\d)\]\](\/)\[\[(\d{1,2}(?:th|st|nd|rd))\]\]", "$1$2$3$4");

 ArticleText=Regex.Replace(ArticleText, @"(?i)([^\[]{4})\[\[(\d?\d)\s(?:January|February|March|April|May|June|July|August|September|October|November|December)\]\](\s?\-?\s?)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d{1,2}(?:th|st|nd|rd)\|(\d{1,2}(?:th|st|nd|rd))\]\]", "$1$2$3$4");
//same again but with ndash instead of hyphen
 ArticleText=Regex.Replace(ArticleText, @"(?i)([^\[]{4})\[\[(\d?\d)\s(?:January|February|March|April|May|June|July|August|September|October|November|December)\]\](\s?&[nm]dash;\s?)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d{1,2}(?:th|st|nd|rd)\|(\d{1,2}(?:th|st|nd|rd))\]\]", "$1$2$3$4");
//same again but with slash instead of hyphen
 ArticleText=Regex.Replace(ArticleText, @"(?i)([^\[]{4})\[\[(\d?\d)\s(?:January|February|March|April|May|June|July|August|September|October|November|December)\]\](\/)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d{1,2}(?:th|st|nd|rd)\|(\d{1,2}(?:th|st|nd|rd))\]\]", "$1$2$3$4");

 ArticleText=Regex.Replace(ArticleText, @"(?i)([^\[]{4})\[\[(\d?\d)\s(?:January|February|March|April|May|June|July|August|September|October|November|December)\]\](\s?\-?\s?)\[\[(\d{1,2}(?:th|st|nd|rd))\]\]", "$1$2$3$4");
//same again but with ndash instead of hyphen
 ArticleText=Regex.Replace(ArticleText, @"(?i)([^\[]{4})\[\[(\d?\d)\s(?:January|February|March|April|May|June|July|August|September|October|November|December)\]\](\s?&[nm]dash;\s?)\[\[(\d{1,2}(?:th|st|nd|rd))\]\]", "$1$2$3$4");
//same again but with slash instead of hyphen
 ArticleText=Regex.Replace(ArticleText, @"(?i)([^\[]{4})\[\[(\d?\d)\s(?:January|February|March|April|May|June|July|August|September|October|November|December)\]\](\/)\[\[(\d{1,2}(?:th|st|nd|rd))\]\]", "$1$2$3$4");

 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d{1,2}(?:th|st|nd|rd)\|(\d{1,2}(?:th|st|nd|rd))\]\]", "$1");
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[\d{1,2}(?:th|st|nd|rd)\s(?:January|February|March|April|May|June|July|August|September|October|November|December)\|(\d{1,2}(?:th|st|nd|rd))\]\]", "$1");

 ArticleText=Regex.Replace(ArticleText, @"\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d{1,2}(?:th|st|nd|rd)\|((?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{1,2}(?:th|st|nd|rd))\]\]", "$1");
//month+day piped into month+day or vice versa
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[\d{1,2}(?:th|st|nd|rd)\s(?:January|February|March|April|May|June|July|August|September|October|November|December)\|((?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d{1,2}(?:th|st|nd|rd))\]\]", "$1");
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d{1,2}(?:th|st|nd|rd)\|(\d{1,2}(?:th|st|nd|rd)\s(?:January|February|March|April|May|June|July|August|September|October|November|December))\]\]", "$1");

//4 digit years piped into 2
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[\d{1,4}\|(\d{1,2}(?:th|st|nd|rd))\]\]", "$1");

//full dates with incorrect 'year in'
 ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\s(?:[0-3][\d]|[\d])\]\]),\s\[\[(\d{1,4})\sin\s[^\]]{1,32}\]\]", "$1 $2");
 ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[(?:[0-3][\d]|[\d])\s(?:January|February|March|April|May|June|July|August|September|October|November|December)\]\])\s\[\[(\d{1,4})\sin\s[^\]]{1,32}\]\]", "$1 $2");
 ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[(?:[0-3][\d]|[\d])\s(?:January|February|March|April|May|June|July|August|September|October|November|December)\]\])\s{{(?:avyear|by|fy|ly|scy|sdy)\|(\d{1,4})}}", "$1 [[$2]]");
 ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\s(?:[0-3][\d]|[\d])\]\]),\s\{\{(?:avyear|by|fy|ly|scy|sdy)\|(\d{1,4})\}\}", "$1 [[$2]]");

    //insert comma to separate date from army unit
 ArticleText=Regex.Replace(ArticleText, @"(?i)(January|February|March|April|May|June|July|August|September|October|November|December) (the \d\d*@th (?:Air(?:borne|)|Arm(?:ou?red|y)|Artillery|Battalion|Brigade|Co(?:mpan|)y|Division|Fleet|Group|Infantry|Land|Panzer|Regiment|Squadron|Sqn)\b)", "$1, $2");

    // remove nowrap template from dm and md dates
 ArticleText=Regex.Replace(ArticleText, @"(?i)(date=)\{\{nowrap\|(?:([0-2]?\d|30|31)(?:[ _]|&nbsp;)(January|February|March|April|May|June|July|August|September|October|November|December))\}\}", "$1$2 $3");
 ArticleText=Regex.Replace(ArticleText, @"(?i)(date=)\{\{nowrap\|(?:(January|February|March|April|May|June|July|August|September|October|November|December)(?:[ _]|&nbsp;)([0-2]?\d|30|31))\}\}", "$1$2 $3");

//remove leading zero from linked date
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\s0(\d)(?:th|st|nd|rd|)\]\]", "[[$1 $2]]");
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[0(\d)(?:th|st|nd|rd|)\s(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\]\]", "[[$1 $2]]");

//delink dates to mdy; strip ordinals
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\s(\d?\d)(?:th|st|nd|rd|)(?:\]\],?\s?\[\[|,?\s)(\d{1,4})\]\]", "$1 $2, $3");
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\s(\d?\d)(?:th|st|nd|rd|)\]\],?\s?(\d{1,4})(\W)", "$1 $2, $3$4");
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\s(\d?\d)(?:th|st|nd|rd|)\]\]", "$1 $2");

 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(\d?\d)(?:th|st|nd|rd|)\s(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)(?:\]\],?\s?\[\[|,?\s)(\d{1,4})\]\]", "$2 $1, $3");
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(\d?\d)(?:th|st|nd|rd|)\s(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\]\],?\s?(\d{1,4})(\W)", "$2 $1, $3$4");
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(\d?\d)(?:th|st|nd|rd|)\s(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\]\]", "$2 $1");

//change deprecated birth and death templates
 ArticleText=Regex.Replace(ArticleText, @"(?i)\|df=ye?s?", "");
// ArticleText=Regex.Replace(ArticleText, @"(?i)(\{\{(?:Birth|Death|launch|release|start|end|film date|Wayback)[^\}\|]*\|)", "$1df=yes|");
// ArticleText=Regex.Replace(ArticleText, @"(?i)(\{\{(?:Birth|Death|launch|release|start|end|film date|Wayback)[^\}\|]*\|)df=ye?s?\|([^}]*df=ye?s?)", "$1$2");

    // eliminating time of day
    ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*author[ ]*=[ ]*)(?:posted|published)(?: by| on|)[\s:](?=\w)", "$1");
    ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:date|archivedate|accessdate|author)[ ]*=[ ]*)[0-2]?\d:[0-5]\d(?:[ ]|&nbsp;)(?:[ap]m |[ap]\.m\. |)([A-Z]{1,2}T|UTC)[\.,]?[ ]?", "$1");
 
    // eliminating days of the week
    ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:date|archivedate|accessdate|author)[ ]*=[ ]*)(?:(?:Mon|Tues|Wednes|Thurs|Fri|Satur|Sun)day,?)\s", "$1");
    ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:date|archivedate|accessdate|author)[ ]*=[ ]*)(?:(?:Mon|Tues?|Wed|Thur?|Fri|Sat|Sun)[\.,]?)\s", "$1");
 
    // eliminating dates placed in author parameter
    ArticleText=Regex.Replace(ArticleText, @"(?i)(\|\s*author\s*=\s*)@month @day,? @yyyy\s?(?:,? \d?\d:\d\d(?:\s*|&nbsp;)(?:[apAP][mM]\s*|)(?:GMT\s*|UTC\s*|[A-Z]{1,2}[DS]T\s*|)|)\|", "|");
    ArticleText=Regex.Replace(ArticleText, @"(?i)(\|\s*author\s*=\s*)@day @month,? @yyyy\s?(?:,? \d?\d:\d\d(?:\s*|&nbsp;)(?:[apAP][mM]\s*|)(?:GMT\s*|UTC\s*|[A-Z]{1,2}[DS]T\s*|)|)\|", "|");

    ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*)Jan\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\s*[\|\}])", "$1January $2, $3");
    ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*)Feb\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\s*[\|\}])", "$1February $2, $3");
    ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*)Mar\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\s*[\|\}])", "$1March $2, $3");
    ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*)Apr\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\s*[\|\}])", "$1April $2, $3");
//    ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*)@Month ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\s*[\|\}])", "$1Fullmonth $2, $3");
    ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*)@Jun\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\s*[\|\}])", "$1June $2, $3");
    ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*)(?:Jly|Jul\.?) ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\s*[\|\}])", "$1July $2, $3");
    ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*)Aug\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\s*[\|\}])", "$1August $2, $3");
    ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*)Sep. ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\s*[\|\}])", "$1September $2, $3");
    ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*)Oct\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\s*[\|\}])", "$1October $2, $3");
    ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*)Nov\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\s*[\|\}])", "$1November $2, $3");
    ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*)Dec\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\s*[\|\}])", "$1December $2, $3");

    ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref[^>]*>(?:[^<]+?[\s\(]|))Jan\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=(?:[^\w\/\-%,<][^<]*?|)<\/ref>)", "$1January $2, $3");
    ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref[^>]*>(?:[^<]+?[\s\(]|))Feb\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=(?:[^\w\/\-%,<][^<]*?|)<\/ref>)", "$1February $2, $3");
    ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref[^>]*>(?:[^<]+?[\s\(]|))Mar\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=(?:[^\w\/\-%,<][^<]*?|)<\/ref>)", "$1March $2, $3");
    ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref[^>]*>(?:[^<]+?[\s\(]|))Apr\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=(?:[^\w\/\-%,<][^<]*?|)<\/ref>)", "$1April $2, $3");
//    ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref[^>]*>(?:[^<]+?[\s\(]|))May ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=(?:[^\w\/\-%,<][^<]*?|)<\/ref>)", "$1Fullmonth $2, $3");
    ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref[^>]*>(?:[^<]+?[\s\(]|))Jun\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=(?:[^\w\/\-%,<][^<]*?|)<\/ref>)", "$1June $2, $3");
    ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref[^>]*>(?:[^<]+?[\s\(]|))(?:Jly|Jul\.?) ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=(?:[^\w\/\-%,<][^<]*?|)<\/ref>)", "$1July $2, $3");
    ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref[^>]*>(?:[^<]+?[\s\(]|))Aug\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=(?:[^\w\/\-%,<][^<]*?|)<\/ref>)", "$1August $2, $3");
    ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref[^>]*>(?:[^<]+?[\s\(]|))Sep. ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=(?:[^\w\/\-%,<][^<]*?|)<\/ref>)", "$1September $2, $3");
    ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref[^>]*>(?:[^<]+?[\s\(]|))Oct\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=(?:[^\w\/\-%,<][^<]*?|)<\/ref>)", "$1October $2, $3");
    ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref[^>]*>(?:[^<]+?[\s\(]|))Nov\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=(?:[^\w\/\-%,<][^<]*?|)<\/ref>)", "$1November $2, $3");
    ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref[^>]*>(?:[^<]+?[\s\(]|))Dec\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=(?:[^\w\/\-%,<][^<]*?|)<\/ref>)", "$1December $2, $3");

    ArticleText=Regex.Replace(ArticleText, @"(?i)([ ]\()Jan\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\)\W)", "$1January $2, $3");
    ArticleText=Regex.Replace(ArticleText, @"(?i)([ ]\()Feb\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\)\W)", "$1February $2, $3");
    ArticleText=Regex.Replace(ArticleText, @"(?i)([ ]\()Mar\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\)\W)", "$1March $2, $3");
    ArticleText=Regex.Replace(ArticleText, @"(?i)([ ]\()Apr\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\)\W)", "$1April $2, $3");
//    ArticleText=Regex.Replace(ArticleText, @"(?i)([ ]\()@Month ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\)\W)", "$1Fullmonth $2, $3");
    ArticleText=Regex.Replace(ArticleText, @"(?i)([ ]\()Jun\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\)\W)", "$1June $2, $3");
    ArticleText=Regex.Replace(ArticleText, @"(?i)([ ]\()(?:Jly|Jul\.?) ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\)\W)", "$1July $2, $3");
    ArticleText=Regex.Replace(ArticleText, @"(?i)([ ]\()Aug\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\)\W)", "$1August $2, $3");
    ArticleText=Regex.Replace(ArticleText, @"(?i)([ ]\()Sep\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\)\W)", "$1September $2, $3");
    ArticleText=Regex.Replace(ArticleText, @"(?i)([ ]\()Oct\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\)\W)", "$1October $2, $3");
    ArticleText=Regex.Replace(ArticleText, @"(?i)([ ]\()Nov\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\)\W)", "$1November $2, $3");
    ArticleText=Regex.Replace(ArticleText, @"(?i)([ ]\()Dec\.? ([1-9]|[1-2][0-9]|30|31), ([1-2][0-9]{3})(?=\)\W)", "$1December $2, $3");

//Slashes
  ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?1\/([12]\d{3})(?![\w\d-])", "$1 January $2, $3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?2\/([12]\d{3})(?![\w\d-])", "$1 February $2, $3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?3\/([12]\d{3})(?![\w\d-])", "$1 March $2, $3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?4\/([12]\d{3})(?![\w\d-])", "$1 April $2, $3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?5\/([12]\d{3})(?![\w\d-])", "$1 May $2, $3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?6\/([12]\d{3})(?![\w\d-])", "$1 June $2, $3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?7\/([12]\d{3})(?![\w\d-])", "$1 July $2, $3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?8\/([12]\d{3})(?![\w\d-])", "$1 August $2, $3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?9\/([12]\d{3})(?![\w\d-])", "$1 September $2, $3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/10\/([12]\d{3})(?![\w\d-])", "$1 October $2, $3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/11\/([12]\d{3})(?![\w\d-])", "$1 November $2, $3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/12\/([12]\d{3})(?![\w\d-])", "$1 December $2, $3");

//2-digit year – UK style
  ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?1\/([4-9]\d)(?![\w\d-])", "$1 January $2, 19$3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?2\/([4-9]\d)(?![\w\d-])", "$1 February $2, 19$3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?3\/([4-9]\d)(?![\w\d-])", "$1 March $2, 19$3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?4\/([4-9]\d)(?![\w\d-])", "$1 April $2, 19$3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?5\/([4-9]\d)(?![\w\d-])", "$1 May $2, 19$3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?6\/([4-9]\d)(?![\w\d-])", "$1 June $2, 19$3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?7\/([4-9]\d)(?![\w\d-])", "$1 July $2, 19$3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?8\/([4-9]\d)(?![\w\d-])", "$1 August $2, 19$3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?9\/([4-9]\d)(?![\w\d-])", "$1 September $2, 19$3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/10\/([4-9]\d)(?![\w\d-])", "$1 October $2, 19$3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/11\/([4-9]\d)(?![\w\d-])", "$1 November $2, 19$3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/12\/([4-9]\d)(?![\w\d-])", "$1 December $2, 19$3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?1\/([01]\d)(?![\w\d-])", "$1 January $2, 20$3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?2\/([01]\d)(?![\w\d-])", "$1 February $2, 20$3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?3\/([01]\d)(?![\w\d-])", "$1 March $2, 20$3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?4\/([01]\d)(?![\w\d-])", "$1 April $2, 20$3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?5\/([01]\d)(?![\w\d-])", "$1 May $2, 20$3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?6\/([01]\d)(?![\w\d-])", "$1 June $2, 20$3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?7\/([01]\d)(?![\w\d-])", "$1 July $2, 20$3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?8\/([01]\d)(?![\w\d-])", "$1 August $2, 20$3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/0?9\/([01]\d)(?![\w\d-])", "$1 September $2, 20$3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/10\/([01]\d)(?![\w\d-])", "$1 October $2, 20$3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/11\/([01]\d)(?![\w\d-])", "$1 November $2, 20$3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)([^\w-])(1[3-9]|[2-3]\d)\/12\/([01]\d)(?![\w\d-])", "$1 December $2, 20$3");

//numerical format with hyphens and dashes (dd-mm-yyyy) to mdy
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([0-2]?\d|30|31)[\-–]0?1[\-–]([1-2]\d{3})(?=\s*[\|\}])", "$1January $2, $3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([0-2]?\d)[\-–]0?2[\-–]([1-2]\d{3})(?=\s*[\|\}])", "$1February $2, $3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([0-2]?\d|30|31)[\-–]0?3[\-–]([1-2]\d{3})(?=\s*[\|\}])", "$1March $2, $3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([0-2]?\d|30|31)[\-–]0?4[\-–]([1-2]\d{3})(?=\s*[\|\}])", "$1April $2, $3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([0-2]?\d|30|31)[\-–]0?5[\-–]([1-2]\d{3})(?=\s*[\|\}])", "$1May $2, $3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([0-2]?\d|30|31)[\-–]0?6[\-–]([1-2]\d{3})(?=\s*[\|\}])", "$1June $2, $3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([0-2]?\d|30|31)[\-–]0?7[\-–]([1-2]\d{3})(?=\s*[\|\}])", "$1July $2, $3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([0-2]?\d|30|31)[\-–]0?8[\-–]([1-2]\d{3})(?=\s*[\|\}])", "$1August $2, $3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([0-2]?\d|30|31)[\-–]0?9[\-–]([1-2]\d{3})(?=\s*[\|\}])", "$1September $2, $3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([0-2]?\d|30|31)[\-–]10[\-–]([1-2]\d{3})(?=\s*[\|\}])", "$1October $2, $3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([0-2]?\d|30|31)[\-–]11[\-–]([1-2]\d{3})(?=\s*[\|\}])", "$1November $2, $3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([0-2]?\d|30|31)[\-–]12[\-–]([1-2]\d{3})(?=\s*[\|\}])", "$1December $2, $3");

//improperly formatted access dates with endashes (yyyy–mm–dd) and/or missing zeros to ISO
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*accessdate[ ]*=[ ]*)([1-2]\d{3})[–—]([0-2]?\d)[–—]([0-2]?\d|30|31)(?=\s*[\|\}])", "$1$2-$3-$4"); //ndashes and emdashes
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*accessdate[ ]*=[ ]*)([1-2]\d{3})-(\d)-([0-2]\d|30|31)(?=\s*[\|\}])", "$1$2-0$3-$4"); //ndashes and emdashes
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*accessdate[ ]*=[ ]*)([1-2]\d{3})-([0-1]\d)-(\d)(?=\s*[\|\}])", "$1$2-$3-0$4"); //ndashes and emdashes
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*accessdate[ ]*=[ ]*)([1-2]\d{3})-(\d)-(\d)(?=\s*[\|\}])", "$1$2-0$3-0$4"); //ndashes and emdashes

//improperly formatted dates with endashes (yyyy–mm–dd) and/or missing zeros to dmy
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})–0?1–([0-2]?\d|30|31)(?=\s*[\|\}])", "$1January $3, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})–0?2–([0-2]?\d)(?=\s*[\|\}])", "$1February $3, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})–0?3–([0-2]?\d|30|31)(?=\s*[\|\}])", "$1March $3, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})–0?4–([0-2]?\d|30|31)(?=\s*[\|\}])", "$1April $3, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})–0?5–([0-2]?\d|30|31)(?=\s*[\|\}])", "$1May $3, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})–0?6–([0-2]?\d|30|31)(?=\s*[\|\}])", "$1June $3, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})–0?7–([0-2]?\d|30|31)(?=\s*[\|\}])", "$1July $3, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})–0?8–([0-2]?\d|30|31)(?=\s*[\|\}])", "$1August $3, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})–0?9–([0-2]?\d|30|31)(?=\s*[\|\}])", "$1September $3, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})–10–([0-2]?\d|30|31)(?=\s*[\|\}])", "$1October $3, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})–11–([0-2]?\d|30|31)(?=\s*[\|\}])", "$1November $3, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})–12–([0-2]?\d|30|31)(?=\s*[\|\}])", "$1December $3, $2");

  ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]0?1[\-–]([1-9])(?=\s*[\|\}])", "$1January $3, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]0?2[\-–]([1-9])(?=\s*[\|\}])", "$1February $3, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]0?3[\-–]([1-9])(?=\s*[\|\}])", "$1March $3, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]0?4[\-–]([1-9])(?=\s*[\|\}])", "$1April $3, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]0?5[\-–]([1-9])(?=\s*[\|\}])", "$1May $3, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]0?6[\-–]([1-9])(?=\s*[\|\}])", "$1June $3, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]0?7[\-–]([1-9])(?=\s*[\|\}])", "$1July $3, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]0?8[\-–]([1-9])(?=\s*[\|\}])", "$1August $3, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]0?9[\-–]([1-9])(?=\s*[\|\}])", "$1September $3, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]10[\-–]([1-9])(?=\s*[\|\}])", "$1October $3, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]11[\-–]([1-9])(?=\s*[\|\}])", "$1November $3, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]12[\-–]([1-9])(?=\s*[\|\}])", "$1December $3, $2");

  ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]1[\-–]([0-2]?\d|30|31)(?=\s*[\|\}])", "$1January $3, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]2[\-–](0?[1-9]|[1-2]\d)(?=\s*[\|\}])", "$1February $3, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]3[\-–]([0-2]?\d|30|31)(?=\s*[\|\}])", "$1March $3, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]4[\-–]([0-2]?\d|30|31)(?=\s*[\|\}])", "$1April $3, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]5[\-–]([0-2]?\d|30|31)(?=\s*[\|\}])", "$1May $3, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]6[\-–]([0-2]?\d|30|31)(?=\s*[\|\}])", "$1June $3, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]7[\-–]([0-2]?\d|30|31)(?=\s*[\|\}])", "$1July $3, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]8[\-–]([0-2]?\d|30|31)(?=\s*[\|\}])", "$1August $3, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]9[\-–]([0-2]?\d|30|31)(?=\s*[\|\}])", "$1September $3, $2");
//ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]10[\-–]([0-2]?\d|30|31)(?=\s*[\|\}])", "$1October $3, $2");
//ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]11[\-–]([0-2]?\d|30|31)(?=\s*[\|\}])", "$1November $3, $2");
//ArticleText=Regex.Replace(ArticleText, @"(?i)(\s*=\s*)([1-2]\d{3})[\-–]12[\-–]([0-2]?\d|30|31)(?=\s*[\|\}])", "$1December $3, $2");

	//yyyymmdd_to_dmy
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:archive|)date[ ]*=[ ]*)(?:\[\[)?([1-2][0-9]{3})(?:\]\]-\[\[|-)0?1-(0[1-9]|[1-2][0-9]|30|31)(?:\]\])?", "$1January $3, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:archive|)date[ ]*=[ ]*)(?:\[\[)?([1-2][0-9]{3})(?:\]\]-\[\[|-)0?2-(0[1-9]|[1-2][0-9]|30|31)(?:\]\])?", "$1February $3, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:archive|)date[ ]*=[ ]*)(?:\[\[)?([1-2][0-9]{3})(?:\]\]-\[\[|-)0?3-(0[1-9]|[1-2][0-9]|30|31)(?:\]\])?", "$1March $3, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:archive|)date[ ]*=[ ]*)(?:\[\[)?([1-2][0-9]{3})(?:\]\]-\[\[|-)0?4-(0[1-9]|[1-2][0-9]|30|31)(?:\]\])?", "$1April $3, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:archive|)date[ ]*=[ ]*)(?:\[\[)?([1-2][0-9]{3})(?:\]\]-\[\[|-)0?5-(0[1-9]|[1-2][0-9]|30|31)(?:\]\])?", "$1May $3, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:archive|)date[ ]*=[ ]*)(?:\[\[)?([1-2][0-9]{3})(?:\]\]-\[\[|-)0?6-(0[1-9]|[1-2][0-9]|30|31)(?:\]\])?", "$1June $3, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:archive|)date[ ]*=[ ]*)(?:\[\[)?([1-2][0-9]{3})(?:\]\]-\[\[|-)0?7-(0[1-9]|[1-2][0-9]|30|31)(?:\]\])?", "$1July $3, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:archive|)date[ ]*=[ ]*)(?:\[\[)?([1-2][0-9]{3})(?:\]\]-\[\[|-)0?8-(0[1-9]|[1-2][0-9]|30|31)(?:\]\])?", "$1August $3, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:archive|)date[ ]*=[ ]*)(?:\[\[)?([1-2][0-9]{3})(?:\]\]-\[\[|-)0?9-(0[1-9]|[1-2][0-9]|30|31)(?:\]\])?", "$1September $3, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:archive|)date[ ]*=[ ]*)(?:\[\[)?([1-2][0-9]{3})(?:\]\]-\[\[|-)10-(0[1-9]|[1-2][0-9]|30|31)(?:\]\])?", "$1October $3, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:archive|)date[ ]*=[ ]*)(?:\[\[)?([1-2][0-9]{3})(?:\]\]-\[\[|-)11-(0[1-9]|[1-2][0-9]|30|31)(?:\]\])?", "$1November $3, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:archive|)date[ ]*=[ ]*)(?:\[\[)?([1-2][0-9]{3})(?:\]\]-\[\[|-)12-(0[1-9]|[1-2][0-9]|30|31)(?:\]\])?", "$1December $3, $2");

  ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)(0[1-9]|[1-2][0-9]|30|31)-0?1-([1-2][0-9]{3})?", "$1January $2, $3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)(0[1-9]|[1-2][0-9])-0?2-([1-2][0-9]{3})?", "$1February $2, $3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)(0[1-9]|[1-2][0-9]|30|31)-0?3-([1-2][0-9]{3})?", "$1March $2, $3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)(0[1-9]|[1-2][0-9]|30|31)-0?4-([1-2][0-9]{3})?", "$1April $2, $3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)(0[1-9]|[1-2][0-9]|30|31)-0?5-([1-2][0-9]{3})?", "$1May $2, $3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)(0[1-9]|[1-2][0-9]|30|31)-0?6-([1-2][0-9]{3})?", "$1June $2, $3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)(0[1-9]|[1-2][0-9]|30|31)-0?7-([1-2][0-9]{3})?", "$1July $2, $3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)(0[1-9]|[1-2][0-9]|30|31)-0?8-([1-2][0-9]{3})?", "$1August $2, $3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)(0[1-9]|[1-2][0-9]|30|31)-0?9-([1-2][0-9]{3})?", "$1September $2, $3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)(0[1-9]|[1-2][0-9]|30|31)-10-([1-2][0-9]{3})?", "$1October $2, $3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)(0[1-9]|[1-2][0-9]|30|31)-11-([1-2][0-9]{3})?", "$1November $2, $3");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)(0[1-9]|[1-2][0-9]|30|31)-12-([1-2][0-9]{3})?", "$1December $2, $3");

  ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)([1-2][0-9]{3}) (January )(0[1-9]|[1-2][0-9]|30|31)", "$1$3$4, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)([1-2][0-9]{3}) (February )(0[1-9]|[1-2][0-9])", "$1$3$4, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)([1-2][0-9]{3}) (March )(0[1-9]|[1-2][0-9]|30|31)", "$1$3$4, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)([1-2][0-9]{3}) (April )(0[1-9]|[1-2][0-9]|30|31)", "$1$3$4, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)([1-2][0-9]{3}) (May )(0[1-9]|[1-2][0-9]|30|31)", "$1$3$4, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)([1-2][0-9]{3}) (June )(0[1-9]|[1-2][0-9]|30|31)", "$1$3$4, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)([1-2][0-9]{3}) (July )(0[1-9]|[1-2][0-9]|30|31)", "$1$3$4, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)([1-2][0-9]{3}) (August )(0[1-9]|[1-2][0-9]|30|31)", "$1$3$4, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)([1-2][0-9]{3}) (September )(0[1-9]|[1-2][0-9]|30|31)", "$1$3$4, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)([1-2][0-9]{3}) (October )(0[1-9]|[1-2][0-9]|30|31)", "$1$3$4, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)([1-2][0-9]{3}) (November )(0[1-9]|[1-2][0-9]|30|31)", "$1$3$4, $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(date[ ]*=[ ]*)([1-2][0-9]{3}) (December )(0[1-9]|[1-2][0-9]|30|31)", "$1$3$4, $2");

  ArticleText=Regex.Replace(ArticleText, @"(?i)([^\d\w\/\-%,])([12]\d{3}-\d\d-\d\d)(<\s?\/ref.*?>)", "$1$2 $3");

//code to convert ref ISO-dates outside citation templates
  ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-01-0(\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2January $4, $3$5$6");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-02-0(\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2February $4, $3$5$6");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-03-0(\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2March $4, $3$5$6");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-04-0(\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2April $4, $3$5$6");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-05-0(\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2May $4, $3$5$6");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-06-0(\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2June $4, $3$5$6");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-07-0(\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2July $4, $3$5$6");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-08-0(\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2August $4, $3$5$6");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-09-0(\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2September $4, $3$5$6");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-10-0(\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2October $4, $3$5$6");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-11-0(\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2November $4, $3$5$6");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-12-0(\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2December $4, $3$5$6");

  ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-01-([1-3]\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2January $4, $3$5$6");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-02-([1-3]\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2February $4, $3$5$6");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-03-([1-3]\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2March $4, $3$5$6");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-04-([1-3]\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2April $4, $3$5$6");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-05-([1-3]\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2May $4, $3$5$6");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-06-([1-3]\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2June $4, $3$5$6");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-07-([1-3]\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2July $4, $3$5$6");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-08-([1-3]\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2August $4, $3$5$6");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-09-([1-3]\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2September $4, $3$5$6");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-10-([1-3]\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2October $4, $3$5$6");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-11-([1-3]\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2November $4, $3$5$6");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref.*?>[^<]+?)(\s\()([12]\d{3})-12-([1-3]\d)(\)[^\w\/\-%,])([^<]*?<\s?\/ref.*?>)", "$1$2December $4, $3$5$6");

//convert dm-dmy date ranges to md-mdy
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\D\W)([0-2]?\d|30|31)(?:th|st|nd|rd|)((?:,?\s[0-3]?\d(?:th|st|nd|rd|)){0,6}),?(\/|\s?(?:[-–]|&ndash;)\s?|\s(?:and|to|&)\s)([0-2]?\d|30|31)(?:th|st|nd|rd|) (Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|)),?\s(?:of\s|)(\d{3,4}\W\D)", "$1$6 $2$3$4$5, $7");
//test code  ArticleText=Regex.Replace(ArticleText, @"(?i)(\D\W)([0-2]?\d|30|31)(?:th|st|nd|rd|)((?:,?\s[0-3]?\d(?:th|st|nd|rd|)){0,6}),? ([0-2]?\d|30|31)(?:th|st|nd|rd|)\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|)),?\s(?:of\s)?(\d{3,4}\W\D)", "$1$5 $2$3$4, $6");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\D\W)([0-2]?\d|30|31)(?:th|st|nd|rd|)((?:,?\s[0-3]?\d(?:th|st|nd|rd|)){0,6}), ([0-2]?\d|30|31)(?:th|st|nd|rd|)\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))(?=\W\D|[ ]*\r)", "$1$5 $2$3$4");

//convert d,d,dm date ranges to md,d,d,  (multiple, separated by commas)
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\D\W)([1-2]?\d|30|31)(?:th|st|nd|rd|)((?:,?\s[0-3]?\d(?:th|st|nd|rd|)){0,6}),?(\/|\s?(?:[-–]|&ndash;)\s?|\s(?:and|to|&)\s)([0-2]?\d|30|31)(?:th|st|nd|rd|)\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))(?=\W\D|[ ]*\r)", "$1$6 $2$3$4$5");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\D\W)((?:[1-3]?\d(?:th|st|nd|rd|),?\s){1,6})((?:and|to|&|&ndash;)\s)([0-2]?\d|30|31)(?:th|st|nd|rd|)\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))(?=\W\D|[ ]*\r)", "$1$5 $2$3$4");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\D\W)([1-2]?\d|30|31)(?:th|st|nd|rd|)((?:,?\s[1-3]?\d(?:th|st|nd|rd|)){1,6})\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))(?=\W\D|[ ]*\r)", "$1$4 $2$3");
//convert md date ranges to dm  (simple, separated by hyphens and dashes  or 'to')
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\D\W)([1-2]?\d|30|31)(?:th|st|nd|rd|)(\s?(?:[-–]|&ndash;)\s?|\sto\s)(?:\2\s|)([0-2]?\d|30|31)(?:th|st|nd|rd|)\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))(?=\W\D|[ ]*\r)", "$1$5 $2$3$4");

// 'dm, dm,' to 'md, md,'
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\D)([0-2]?\d|30|31)\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|)),( [0-2]?\d|30|31) (Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))([,\.]\W\D)", "$1$3 $2, $5 $4$6");

//convert simple mdy dates to dmy
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\D\W)([0-2]?\d|30|31)(?:th|st|nd|rd|)\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|)),?\s(\d{1,4}\s?(?:AD|BC|CE|BCE)\W\D)", "$1$3 $2, $4");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\D\W)([0-2]?\d|30|31)(?:th|st|nd|rd|)\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|)),?\s([12]\d{3})(?=\W\D|[ ]*\r)", "$1$3 $2, $4");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\D\W)([0-2]?\d|30|31)(?:th|st|nd|rd|)\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))(?=\W\D|[ ]*\r)", "$1$3 $2");

//Month+day_number "March 7th" -> "March 7"
 ArticleText=Regex.Replace(ArticleText, @"(?i)(\D\W)(Jan(?:uary|.)|Feb(?:ruary|.)|Mar(?:ch|.)|Apr(?:il|.)|May|June?|July?|Aug(?:ust|.)|Sep(?:tember|.)|Oct(?:ober|.)|Nov(?:ember|.)|Dec(?:ember|.))\s([0-2]?\d|30|31)(?:th|st|nd|rd|)(\W\D)", "$1$2 $3$4");

//year
 ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[([12]?\d{1,3})\]\]", "$1");

	//remove leading zero from nonlinked date
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\D\W)0(\d)(?:th|st|nd|rd|)\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s(\d{4})(?=\W\D|[ ]*\r)", "$1$3 $2, $4");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\D\W)0(\d)(?:th|st|nd|rd|)\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))(?=\W\D|[ ]*\r)", "$1$3 $2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\D\W)(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s0(\d)(?:th|st|nd|rd|),\s(\d{4})(?=\W\D|[ ]*\r)", "$1$2 $3, $4");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\D\W)(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))0(\d)(?:th|st|nd|rd|)(?=\W\D|[ ]*\r)", "$1$2 $3");


//rem duplicated months in date formats //code not functioning as intended
 ArticleText=Regex.Replace(ArticleText, @"(?i)(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\s([1-2]?\d|30|31)(?:th|st|nd|rd|)\s+(to|[\-–—])\s\1\s+([1-2]?\d|30|31)(?:th|st|nd|rd|)(?=\W)", "$1 $2 $3 $4");

//rem ordinals and redundant spaces (and commas) in date ranges
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\D)(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\s0?([1-2]?\d|30|31)(?:th|st|nd|rd|)\s+(to|[\-–—])\s+0?([1-2]?\d|30|31)(?:th|st|nd|rd|)(?=\W)", "$1$2 $3 $4 $5");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\D)(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\s0?([1-2]?\d|30|31)(?:th|st|nd|rd|),\s?(\d{3,4})(?=\W)", "$1$2 $3, $4");

//replace 'as of [date]' with 'updated [date]'
 ArticleText=Regex.Replace(ArticleText, @"(?i)(\'\')As of\s([0-2]?\d|30|31)\s(Jan(?:uary|.)|Feb(?:ruary|.)|Mar(?:ch|.)|Apr(?:il|.)|May|June?|July?|Aug(?:ust|.)|Sep(?:tember|.)|Oct(?:ober|.)|Nov(?:ember|.)|Dec(?:ember|.)),\s?(20\d{2})(?=\.?\')", "$1Updated $3 $2, $4");

//remove Crores and Lakhs in templates converting to USD
	ArticleText=Regex.Replace(ArticleText, @"\{\{INR Convert[ ]*\|[ ]*", "{{INRConvert|"); //removing spaces (redirects to shortcut)

	ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|-?\d{2,})8\.[5-9]\d*[ ]*(\|c(?:\|-?\d|)\}\})", "${1}9$2");
	ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|-?\d{2,})7\.[5-9]\d*[ ]*(\|c(?:\|-?\d|)\}\})", "${1}8$2");
	ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|-?\d{2,})6\.[5-9]\d*[ ]*(\|c(?:\|-?\d|)\}\})", "${1}7$2");
	ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|-?\d{2,})5\.[5-9]\d*[ ]*(\|c(?:\|-?\d|)\}\})", "${1}6$2");
	ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|-?\d{2,})4\.[5-9]\d*[ ]*(\|c(?:\|-?\d|)\}\})", "${1}5$2");
	ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|-?\d{2,})3\.[5-9]\d*[ ]*(\|c(?:\|-?\d|)\}\})", "${1}4$2");
	ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|-?\d{2,})2\.[5-9]\d*[ ]*(\|c(?:\|-?\d|)\}\})", "${1}3$2");
	ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|-?\d{2,})1\.[5-9]\d*[ ]*(\|c(?:\|-?\d|)\}\})", "${1}2$2");
	ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|-?\d{2,})0\.[5-9]\d*[ ]*(\|c(?:\|-?\d|)\}\})", "${1}1$2");
	ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|-?\d{3,})\.[0-4]\d*[ ]*(\|c(?:\|-?\d|)\}\})", "$1$2");

	ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|)(-?\d+)0000[ ]*\|l(\|-?\d|)(?:\|nolink=yes|)((?:\|year=\d{4}|)\}\})", "$1$2|b$3$4");
	ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|)(-?\d+)(\d\d)[0-4][ ]*\|l(\|-?\d|)(?:\|nolink=yes|)((?:\|year=\d{4}|)\}\})", "$1$2$3|m$3$4");
	ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|)(-?\d{2,})[0-4][ ]*\|l(\|-?\d|)(?:\|nolink=yes|)((?:\|year=\d{4}|)\}\})", "$1$2|m$3$4");
	ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|)(-?\d+)0[ ]*\|l(\|-?\d|)(?:\|nolink=yes|)((?:\|year=\d{4}|)\}\})", "$1$2|m$3$4");
	ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|)(-?\d+)(\d)[ ]*\|l(\|-?\d|)(?:\|nolink=yes|)((?:\|year=\d{4}|)\}\})", "$1$2.$3|m$4$5");
	ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|)(-?\d+)[ ]*\|l(\|-?\d|)(?:\|nolink=yes|)((?:\|year=\d{4}|)\}\})", "$1${2}00000$3$4");
	ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|)(-?\d+)\.(\d)0?[ ]*\|l(\|-?\d|)(?:\|nolink=yes|)((?:\|year=\d{4}|)\}\})", "$1$2${3}0000$4$5");
	ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|)(-?\d+)\.(\d)(\d)[ ]*\|l(\|-?\d|)(?:\|nolink=yes|)((?:\|year=\d{4}|)\}\})", "$1$2$3${4}000$5$6");
//	ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|)(-?\d+)(\d)[ ]*\|l(\|-?\d|)(?:\|nolink=yes|)((?:\|year=\d{4}|)\}\})", "$1$2.$3|m$4$5");
	ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|)(-?\d+)\.(\d)[ ]*\|c(\|-?\d|)(?:\|nolink=yes|)((?:\|year=\d{4}|)\}\})", "$1$2$3|m$4$5");
	ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|)(-?\d+)\.(\d)(\d+)[ ]*\|c(\|-?\d|)(?:\|nolink=yes|)((?:\|year=\d{4}|)\}\})", "$1$2$3.$4|m$5$6");
	ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|)(-?\d+)0[0-4][ ]*\|c(\|-?\d|)(?:\|nolink=yes|)((?:\|year=\d{4}|)\}\})", "$1$2|b$3$4");
	ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|)(-?\d+)(\d)0[ ]*\|c(\|-?\d|)(?:\|nolink=yes|)((?:\|year=\d{4}|)\}\})", "$1$2.$3|b$4$5");
	ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|)(-?\d{3,})([0-4]\d)[ ]*\|c(\|-?\d|)(?:\|nolink=yes|)((?:\|year=\d{4}|)\}\})", "$1$2|b$4$5");
ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|)(-?\d+)(\d\d)[ ]*\|c(\|-?\d|)(?:\|nolink=yes|)((?:\|year=\d{4}|)\}\})", "$1$2.$3|b$4$5");
	ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|)(-?\d+)[ ]*\|c(\|-?\d|)(?:\|nolink=yes|)((?:\|year=\d{4}|)\}\})", "$1${2}0|m$3$4");

	ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|-?\d{2,})8\.[5-9]\d*[ ]*(\|[bm](?:\|-?\d|)\}\})", "${1}9$2");
	ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|-?\d{2,})7\.[5-9]\d*[ ]*(\|[bm](?:\|-?\d|)\}\})", "${1}8$2");
	ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|-?\d{2,})6\.[5-9]\d*[ ]*(\|[bm](?:\|-?\d|)\}\})", "${1}7$2");
	ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|-?\d{2,})5\.[5-9]\d*[ ]*(\|[bm](?:\|-?\d|)\}\})", "${1}6$2");
	ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|-?\d{2,})4\.[5-9]\d*[ ]*(\|[bm](?:\|-?\d|)\}\})", "${1}5$2");
	ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|-?\d{2,})3\.[5-9]\d*[ ]*(\|[bm](?:\|-?\d|)\}\})", "${1}4$2");
	ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|-?\d{2,})2\.[5-9]\d*[ ]*(\|[bm](?:\|-?\d|)\}\})", "${1}3$2");
	ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|-?\d{2,})1\.[5-9]\d*[ ]*(\|[bm](?:\|-?\d|)\}\})", "${1}2$2");
	ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|-?\d{2,})0\.[5-9]\d*[ ]*(\|[bm](?:\|-?\d|)\}\})", "${1}1$2");
	ArticleText=Regex.Replace(ArticleText, @"(\{INRConvert\|-?\d{3,})\.[0-4]\d*[ ]*(\|[bm](?:\|-?\d|)\}\})", "$1$2");
//remove Crores and Lahks not in templates
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\d+)[ ]?(?:lakh|\[\[lakh\]\])[\- ](?:crores?|\[\[crores?\]\])", "$1&nbsp;trillion ([[Long and short scales|short scale]])");

	ArticleText=Regex.Replace(ArticleText, @"(?i)(\d+)(\d),?(\d)\d{2}(?:\.\d{,2}|)[ ]?(?:lacs?\b|lakhs?\b|\[\[lakh(?:\|l|\|lac|)\]\]s?)", "$1.$2$3&nbsp;billion");
	ArticleText=Regex.Replace(ArticleText, @"(?i)(?:(\d+),|)(\d{2,})(\d)(?:\.[0-4]\d|)[ ]?(?:lacs?\b|lakhs?\b|\[\[lakh(?:\|l|\|lac|)\]\]s?)", "$1$2.$3&nbsp;million");
	ArticleText=Regex.Replace(ArticleText, @"(?i)(?:(\d+),|)(\d+)\.(\d)[ ]?(?:lacs?\b|lakhs?\b|\[\[lakh(?:\|l|\|lac|)\]\]s?)", "$1$2${3}0,000");
	ArticleText=Regex.Replace(ArticleText, @"(?i)(?:(\d+),|)(\d+)\.(\d)(\d)[ ]?(?:lacs?\b|lakhs?\b|\[\[lakh(?:\|l|\|lac|)\]\]s?)", "$1$2$3$4,000");
	ArticleText=Regex.Replace(ArticleText, @"(?i)(?:(\d+),|)(\d+)0,000[ ]?(?:lacs?\b|lakhs?\b|\[\[lakh(?:\|l|\|lac|)\]\]s?)", "$1$2&nbsp;billion");
	ArticleText=Regex.Replace(ArticleText, @"(?i)(?:(\d+),|)(\d+)0[ ]?(?:lacs?\b|lakhs?\b|\[\[lakh(?:\|l|\|lac|)\]\]s?)", "$1$2&nbsp;million");
	ArticleText=Regex.Replace(ArticleText, @"(?i)(?:(\d+),|)(\d+)(\d)[ ]?(?:lacs?\b|lakhs?\b|\[\[lakh(?:\|l|\|lac|)\]\]s?)", "$1$2.$3&nbsp;million");
	ArticleText=Regex.Replace(ArticleText, @"(?i)(?:(\d+),|)(\d+)[ ]?(?:lacs?\b|lakhs?\b|\[\[lakh(?:\|l|\|lac|)\]\]s?)", "$1${2}00,000");
	ArticleText=Regex.Replace(ArticleText, @"(?i)(?:(\d+),|)(\d+)(\d)[ ]?(?:lacs?\b|lakhs?\b|\[\[lakh(?:\|l|\|lac|)\]\]s?)", "$1$2.$3&nbsp;million");
	ArticleText=Regex.Replace(ArticleText, @"(?i)(?:(\d+),|)(\d+)\.(\d)[0-4]?[ ]?(?:crores?|\[\[crore(?:\|cr|\|crores|)\]\]s?)", "$1$2$3&nbsp;million");
	ArticleText=Regex.Replace(ArticleText, @"(?i)(?:(\d+),|)(\d+)\.(\d)(\d+)[ ]?(?:crores?|\[\[crore(?:\|cr|\|crores|)\]\]s?)", "$1$2$3.$4&nbsp;million");
	ArticleText=Regex.Replace(ArticleText, @"(?i)(?:(\d+),|)(\d+)0[0-4][ ]?(?:crores?|\[\[crore(?:\|cr|\|crores|)\]\]s?)", "$1$2&nbsp;billion");
	ArticleText=Regex.Replace(ArticleText, @"(?i)(?:(\d+),|)(\d+)(\d\d)[ ]?(?:crores?|\[\[crore(?:\|cr|\|crores|)\]\]s?)", "$1$2.$3&nbsp;billion");
	ArticleText=Regex.Replace(ArticleText, @"(?i)(?:(\d+),|)(\d+)[ ]?(?:crores?|\[\[crore(?:\|cr|\|crores|)\]\]s?)", "$1${2}0&nbsp;million");

	ArticleText=Regex.Replace(ArticleText, @"(?i)\b(one)[ ](?:lacs?\b|lakhs?|\[\[lakhs?(?:\|l|\|lac|)\]\])", "$1 hundred thousand");
	ArticleText=Regex.Replace(ArticleText, @"(?i)(?:one)[ ]?(?:crores?|\[\[crore(?:\|cr|\|crores|)\]\]s?)", "ten&nbsp;million");
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\d+,|)(\d{3,})\.[0-4]\d?(&nbsp;[bm]illion)", "$1$2$3");
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\d+,|)(\d{2,})1\.[5-9]\d?(&nbsp;[bm]illion)", "$1${2}2$3");
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\d+,|)(\d{2,})2\.[5-9]\d?(&nbsp;[bm]illion)", "$1${2}3$3");
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\d+,|)(\d{2,})3\.[5-9]\d?(&nbsp;[bm]illion)", "$1${2}4$3");
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\d+,|)(\d{2,})4\.[5-9]\d?(&nbsp;[bm]illion)", "$1${2}5$3");
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\d+,|)(\d{2,})5\.[5-9]\d?(&nbsp;[bm]illion)", "$1${2}6$3");
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\d+,|)(\d{2,})6\.[5-9]\d?(&nbsp;[bm]illion)", "$1${2}7$3");
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\d+,|)(\d{2,})7\.[5-9]\d?(&nbsp;[bm]illion)", "$1${2}8$3");
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\d+,|)(\d{2,})8\.[5-9]\d?(&nbsp;[bm]illion)", "$1${2}9$3");
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\d+,|)(\d+)\.0[0-4]?(&nbsp;[bm]illion)", "$1$2$3");

// Indian commas
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\W)(\d{1,3}),(\d\d),(\d\d),(\d\d),(\d\d),(\d\d\d)(?=[ \.,])", "$1{{formatnum:$2$3$4$5$6$7}}");
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\W)(\d{1,3}),(\d\d),(\d\d),(\d\d),(\d\d\d)(?=[ \.,])", "$1{{formatnum:$2$3$4$5$6}}");
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\W)(\d{1,3}),(\d\d),(\d\d),(\d\d\d)(?=[ \.,])", "$1{{formatnum:$2$3$4$5}}");
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\W)(\d\d?),(\d\d),(\d\d\d)(?=[ \.,]|\/-)", "$1{{formatnum:$2$3$4}}");

	ArticleText=Regex.Replace(ArticleText, @"(?i)([$£₤¥€]) (\d)", "$1$2");
	ArticleText=Regex.Replace(ArticleText, @"(\{\{(?:INR|Indian Rupee)\}\}|Rs\.?) (\d+)", "$1$2");

// removing references to other WP articles and 'external' WP links
	ArticleText=Regex.Replace(ArticleText, @"(?i)<ref>https?:\/\/\w{2}\.wik(?:ipedia|tionary)\.org\/wiki\/[^\s\]<]*<\/ref>", "");
	ArticleText=Regex.Replace(ArticleText, @"(?i)<ref>\[https?:\/\/\w{2}\.wik(?:ipedia|tionary)\.org\/wiki\/[^\s\]]*[ ]+[\w\d][^\]]*\]<\/ref>", "");

	ArticleText=Regex.Replace(ArticleText, @"(?i)[ ]\[https?:\/\/en\.wikipedia\.org\/wiki\/[^\s\]]*[ ]+([\w][^\]]*)\]", " [[$1]]");

//unprotect certain dates
 ArticleText=Regex.Replace(ArticleText, @"(?i)(.)♫(.)", "$1$2");

	//de-tagging for 'Use dmy dates|date='
  ArticleText=Regex.Replace(ArticleText, @"(?i)\{\{(use (dmy|mdy) dates|dmy|mdy)(\|[^}]*)?\}\}\n?", "");
  ArticleText=Regex.Replace(ArticleText, @"(?i)\{\{(use (British( \(Oxford\)|)|Indian|Irish) English|EngvarB)(\|[^}]*)?\}\}\n?", "");
  ArticleText=Regex.Replace(ArticleText, @"(?i)\{\{reflist\|\d\}\}", "{{reflist|30em}}");

///General formatting
//adding piping to parentheticals
 	ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[([^\[\]\(\)\|:]*)[ _](\([^\[\]\(\)\|]*(?:album|band|born \d{4}|film|magazine|newspaper|song)\))(\]\])", "[[$1 $2|$1$3");	//adding piping to parentheticals
//add correct hyphenation
 	ArticleText=Regex.Replace(ArticleText, @"\b([2-9]|\d{2,3}|half|quarter|two|three|four|five|six|seven|eight|nine|ten) (minute|hour|day|week|month|year|litre|litre|degree|inch|foot|yard|mile|metre|metre|man|page|point|word|dollar|cent|floor|store?y|room)\b", "$1-$2");
 	ArticleText=Regex.Replace(ArticleText, @"(?i)\b(two|three|four|five|six|seven|eight|nine|ten) (halves|thirds|quarters|(?:four|fif|six|seven|eigh|nin|ten)ths)\b", "$1-$2");
  	ArticleText=Regex.Replace(ArticleText, @"(?i)\b((?:[2-9]|\d{2,3})-(?:month|year)) (old)\b", "$1-$2");
	ArticleText=Regex.Replace(ArticleText, @"(\bnon) ([A-Z]?[a-z]+)", "$1-$2");

//improper capitalisation within section headings
	ArticleText=Regex.Replace(ArticleText, @"(==[ ]*External )(Links)(?=[ ]*=)", "$1links");
	ArticleText=Regex.Replace(ArticleText, @"(==[ ]*See )(Also)(?=[ ]*=)", "$1also");
	ArticleText=Regex.Replace(ArticleText, @"(==[ ]*)Notable ([A-Z]\w*?)", "$1$2");
	ArticleText=Regex.Replace(ArticleText, @"(==[ ]*Box )O(ffice)(?=[ ]*=)", "$1o$2");
	ArticleText=Regex.Replace(ArticleText, @"(==[ ]*[\w]+? and )A(wards?|chievements?)(?=[ ]*=)", "$1a$2");
	ArticleText=Regex.Replace(ArticleText, @"(==[ ]*[\w\s]+? )A(lbums?)(?=[ ]*=)", "$1a$2");
	ArticleText=Regex.Replace(ArticleText, @"(==[ ]*[\w\s]+? )C(areer|hampionships|haracters|ompositions)(?=[ ]*=)", "$1c$2");
	ArticleText=Regex.Replace(ArticleText, @"(==[ ]*[\w\s]+? )E(ducation)(?=[ ]*=)", "$1e$2");
//	ArticleText=Regex.Replace(ArticleText, @"(==[ ]*[\w\s]+? )G(roup)(?=[ ]*=)", "$1g$2");
	ArticleText=Regex.Replace(ArticleText, @"(==[ ]*[\w\s]+? )H(istory|onou?rs)(?=[ ]*=)", "$1h$2");
	ArticleText=Regex.Replace(ArticleText, @"(==[ ]*[\w\s]+? )L(evel|ife|isting)(?=[ ]*=)", "$1l$2");
	ArticleText=Regex.Replace(ArticleText, @"(==[ ]*(?:1st|2nd|3rd|\dth) )M(atch)", "$1m$2");
	ArticleText=Regex.Replace(ArticleText, @"(==[ ]*(?:1st|2nd|3rd|\dth) )F(inal)", "$1f$2");
	ArticleText=Regex.Replace(ArticleText, @"(==[ ]*(?:First|Second|Third|Fourth|[1-4](?:st|nd|rd|th)) )P(lace)(?=[ ]*==)", "$1p$2");
	ArticleText=Regex.Replace(ArticleText, @"(==[ ]*(?:First|Second|Third|Fourth|[1-4](?:st|nd|rd|th)) )Q(uarter)(?=[ ]*==)", "$1q$2");
	ArticleText=Regex.Replace(ArticleText, @"(==[ ]*(?:First|Second|Third|Fourth|[1-4](?:st|nd|rd|th)) )R(ound)(?=[ ]*==)", "$1r$2");
	ArticleText=Regex.Replace(ArticleText, @"(==[ ]*(?:CFL|N[BFH]L) )C(oaching )[Rr](ecords?)(?=[ ]*=)", "$1c$2r$3");
	ArticleText=Regex.Replace(ArticleText, @"(==[ ]*[\w\s]+? )R(ankings?|eading|esults?|ecords?|eception|ecognition)(?=[ ]*=)", "$1r$2");
	ArticleText=Regex.Replace(ArticleText, @"(==[ ]*[-\w\s]+? )C(areer )S(tatistics)(?=[ ]*=)", "$1c$2s$3");
	ArticleText=Regex.Replace(ArticleText, @"(==[ ]*[\w\s]+? )S(eason|quad|tyle|tage|tatistics)(?=[ ]*=)", "$1s$2");
	ArticleText=Regex.Replace(ArticleText, @"(==[ ]*[\w\s]+? )P(ersonnel)(?=[ ]*=)", "$1p$2");
	ArticleText=Regex.Replace(ArticleText, @"(==[ ]*[\w\s]+? )R(esponses?)(?=[ ]*=)", "$1p$2");
	ArticleText=Regex.Replace(ArticleText, @"(==[ ]*[\w\s]+? )T(ournaments?)(?=[ ]*=)", "$1t$2");
	ArticleText=Regex.Replace(ArticleText, @"(==[ ]*[\w\s]+? )Y(ears)(?=[ ]*=)", "$1y$2");

	ArticleText=Regex.Replace(ArticleText, @"(==[ ]*Exhibition )S(chedule)(?=[ ]*=)", "$1s$2");
	ArticleText=Regex.Replace(ArticleText, @"(==[ ]*Regular )Season Schedule(?=[ ]*=)", "$1season schedule");
	ArticleText=Regex.Replace(ArticleText, @"(==[ ]*Right )[Oo]f Reply(?=[ ]*=)", "$1of reply");
		ArticleText=Regex.Replace(ArticleText, @"(==[ ]*Terminated )D(estinations)(?=[ ]*=)", "$1d$2");
	ArticleText=Regex.Replace(ArticleText, @"(==[ ]*Twin )T(owns)(?=[ ]*=)", "$1t$2");
	ArticleText=Regex.Replace(ArticleText, @"(==[ ]*Twin )(Towns [Aa]nd [Ss]ister [Cc]ities)(?=[ ]*=)", "$1towns and sister cities");
	ArticleText=Regex.Replace(ArticleText, @"(==[ ]*Heraldic )(Items)(?=[ ]*=)", "$1items");
	ArticleText=Regex.Replace(ArticleText, @"(==[ ]*Campaign )C(redits)(?=[ ]*=)", "$1c$2");
	ArticleText=Regex.Replace(ArticleText, @"(==[ ]*Combat )C(hronicle)(?=[ ]*=)", "$1c$2");

//other improper capitalisation
	ArticleText=Regex.Replace(ArticleText, @"([ ]*(?:\d\d?\W |)(?:CD |Cassette ))S(ingles?)\b", "$1s$2");
	ArticleText=Regex.Replace(ArticleText, @"([ ]*(?:\d\d?\W |CD |Cassette ))S(ingles?)\b", "$1s$2");
//	ArticleText=Regex.Replace(ArticleText, @"(\d(?:st|nd|rd|th) )C(entur(?:ies|y))(?=[ ]*(=|BC|AD|CE))", "$1c$2"); //transferring to MOSNUM script
//	ArticleText=Regex.Replace(ArticleText, @"(\d(?:st|nd|rd|th) )C(entur(?:ies|y))(?![ -]*(?:Fox|[A-Z]\w*))", "$1c$2");

    ArticleText=Regex.Replace(ArticleText, @"\b(Bowling |Batting )S(tyle)\b", "$1s$2");
	ArticleText=Regex.Replace(ArticleText, @"\b(lef|righ)t-Handed Opening B(atsman)\b", "$1t-handed opening b$2");
	ArticleText=Regex.Replace(ArticleText, @"\b(lef|righ)t-Handed Top Order B(atsman)\b", "$1t-handed top-order b$2");
    ArticleText=Regex.Replace(ArticleText, @"\b([Aa]ll)[- ]R(ounder)\b", "$1-r$2");
    ArticleText=Regex.Replace(ArticleText, @"\b(Wicket)[- ]K(eeper)\b", "$1-k$2");
    ArticleText=Regex.Replace(ArticleText, @"\b(fast)[-– ](medium )B(owler)\b", "$1–$2b$3");
    ArticleText=Regex.Replace(ArticleText, @"\b([Ff]ast |[Mm]edium )B(owler)\b", "$1b$2");
    ArticleText=Regex.Replace(ArticleText, @"\b([Ff]ast|[Ss]low)[-– ](lef|righ)t-[Aa]rm B(owler)\b", "$1 $2-arm b$3");
    ArticleText=Regex.Replace(ArticleText, @"\b(fast)[- ]B(owler)\b", "$1-b$2");
    ArticleText=Regex.Replace(ArticleText, @"\b([Ll]eg|[Oo]ff)[- ][Ss](pin )B(owler)\b", "$1-s$2b$3");

	ArticleText=Regex.Replace(ArticleText, @"\b(st|nd|rd|th) G(rade)\b", "$1 g$2");
//	ArticleText=Regex.Replace(ArticleText, @"(Official )S(ite)", "$1s$2");
//	ArticleText=Regex.Replace(ArticleText, @"([A-Z][a-z]+ )O(fficial )W(ebsite\])", "$1o$2w$3");
	ArticleText=Regex.Replace(ArticleText, @"(\'Further )R(eading)(?=\')", "$1r$2");

        ArticleText=Regex.Replace(ArticleText, @"(\w )A(nd|t) A(n? \w)", "$1a$2 a$3");
        ArticleText=Regex.Replace(ArticleText, @"(\w )A(nd|t) (My \w)", "$1a$2 $3");
        ArticleText=Regex.Replace(ArticleText, @"(\w )A(nd|t) T(he \w)", "$1a$2 t$3");
        ArticleText=Regex.Replace(ArticleText, @"(\w )By A(n? \w)", "$1by a$2");
        ArticleText=Regex.Replace(ArticleText, @"(\w )By (My \w)", "$1by $2");
        ArticleText=Regex.Replace(ArticleText, @"(\w )By T(he \w)", "$1by t$2");
        ArticleText=Regex.Replace(ArticleText, @"(\w )For A(n? \w)", "$1for a$2");
        ArticleText=Regex.Replace(ArticleText, @"(\w )For (My \w)", "$1for $2");
        ArticleText=Regex.Replace(ArticleText, @"(\w )For T(he \w)", "$1for t$2");
        ArticleText=Regex.Replace(ArticleText, @"(\w )In A(n? \w)", "$1in a$2");
        ArticleText=Regex.Replace(ArticleText, @"(\w )In (My \w)", "$1in $2");
        ArticleText=Regex.Replace(ArticleText, @"(\w )In T((?:he|o) \w)", "$1in t$2");
        ArticleText=Regex.Replace(ArticleText, @"(\w )I(nto \w)", "$1i$2");
        ArticleText=Regex.Replace(ArticleText, @"(\w )O(f|n|r) A(n? \w)", "$1o$2 a$3");
        ArticleText=Regex.Replace(ArticleText, @"(\w )O(f|n|r) (My \w)", "$1o$2 $3");
        ArticleText=Regex.Replace(ArticleText, @"(\w )O(f|n|r) T(he \w)", "$1o$2 t$3");
        ArticleText=Regex.Replace(ArticleText, @"(\w )To A(n? \w)", "$1to a$2");
        ArticleText=Regex.Replace(ArticleText, @"(\w )To (My \w)", "$1to $2");
        ArticleText=Regex.Replace(ArticleText, @"(\w )To T(he \w)", "$1to t$2");
        ArticleText=Regex.Replace(ArticleText, @"(\w )With A(n? \w)", "$1with a$2");
        ArticleText=Regex.Replace(ArticleText, @"(\w )With M(y \w)", "$1with M$2");
        ArticleText=Regex.Replace(ArticleText, @"(\w )With T(he \w)", "$1with t$2");

        ArticleText=Regex.Replace(ArticleText, @"(\w )A(t \w)", "$1a$2");
        ArticleText=Regex.Replace(ArticleText, @"(\w )I(n \w)", "$1i$2");
        ArticleText=Regex.Replace(ArticleText, @"(\w )O([fn] \w)", "$1o$2");  //'Or' - false positive (with heraldric Or); 'On' - name (e.g. Ma On Shan)

        ArticleText=Regex.Replace(ArticleText, @"([Rr]unners?)[\- ]U(p\b)", "$1-u$2");
        ArticleText=Regex.Replace(ArticleText, @"([Rr]unner)[\- ][Uu](?:ps)\b", "$1s-up");
        ArticleText=Regex.Replace(ArticleText, @"([Pp]lay)[\- ][Oo](ffs?)", "$1-o$2");
        ArticleText=Regex.Replace(ArticleText, @"(\W[^A-Z]+ )[Qq](uarter)[\- ]F(inal)", "$1q$2-f$3");
        ArticleText=Regex.Replace(ArticleText, @"([Qq]uarter)[\- ]F(inal)", "$1-f$2");
        ArticleText=Regex.Replace(ArticleText, @"(\W[^A-Z]+ )[Ss](emi)[\- ]F(inal)", "$1s$2-f$3");
        ArticleText=Regex.Replace(ArticleText, @"([Ss]emi)[\- ]F(inal)", "$1-f$2");

        ArticleText=Regex.Replace(ArticleText, @"(Bring |Turn )[Ii]t o(n)", "$1It O$2");   //reverting proper name - title of song or work
        ArticleText=Regex.Replace(ArticleText, @"(Carry )o(n [A-Z]\w*|n film)", "$1O$2");   //reverting proper name - 'Carry On' film series
        ArticleText=Regex.Replace(ArticleText, @"(Ma )o(n Shan)", "$1O$2");   //reverting proper name - 'Ma On Shan'
        ArticleText=Regex.Replace(ArticleText, @"(NZ |New Zealand )o(n Air|n Screen)", "$1O$2");   //reverting proper name - 'NZ On Air'
        ArticleText=Regex.Replace(ArticleText, @"in t(he [Aa]ir [Tt]onight)", "In t$1");   //reverting per "In the Air Tonight"
        ArticleText=Regex.Replace(ArticleText, @"in t(he Flesh [Tt]our)", "In t$1");   //reverting per "In the Flesh tour"
        ArticleText=Regex.Replace(ArticleText, @"(\W)o(n This Day)", "$1O$2");   //reverting per "on This Day"
        ArticleText=Regex.Replace(ArticleText, @"(Star Trek )into( Darkness)", "$1Into$2");   //reverting proper name - title of work

    //remove flagicons from country, birth and death etc
    ArticleText=Regex.Replace(ArticleText, @"(?i)((?:birth|death|place|chairman|coach|manager|nationality)\s*=)\s*\{\{flag ?icon\|[^{}]+\}\}", "$1");
    ArticleText=Regex.Replace(ArticleText, @"(?i)(<br ?\/?>)\s*\{\{flag ?icon\|[^{}|]+\}\}", "$1");

//remove scroll bar for reflists
	ArticleText=Regex.Replace(ArticleText, @"(?i)(References ?={1,4}[\n\r][\r\n\s]*)<div class=[^>]*>([\S\s]*?)<\/div>", "$1$2");
	ArticleText=Regex.Replace(ArticleText, @"(?i)((?:Notes ?|References ?)={2,4}\s?[\n\r][\r\n\s]*)(?:\{\{[Rr]eflist\|[2,3]\}\})", "$1{{reflist|colwidth=30em}}");

//rem redundant spaces underlining and punctuation
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\W)[“](\[?\w+)", "$1\"$2");
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\w+\]?)(,|\.|)[”](\W)", "$1\"$2$3");    //quotemark plus incidental LQ
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\W)[‘`´’′](\[?\w+)", "$1\'$2");
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\w+\]?\.?)[‘`´’′](\W)", "$1\'$2");		// replace various single quotes and prime symbol with straight apostrophe
	ArticleText=Regex.Replace(ArticleText, @"(?i)([\w;,\]\)>] ) +([\[\w(])", "$1$2");	//rem multiple spaces except when preceded by full stop
	ArticleText=Regex.Replace(ArticleText, @"(?i)(^\.U\.)[ ]+((?:S|K)\.)", "$1$2");  //U. S. and U. K. to U.S. and U.K.
	ArticleText=Regex.Replace(ArticleText, @"(?i)(<\/?ref(?: name=[^\<\>\/]*?|)>)[ ,\. ]*(<ref)", "$1$2");	// remove punctuation between ref tags
	ArticleText=Regex.Replace(ArticleText, @"(?i)[ ]{1,3}(<\/?ref(?:>| >| n))", "$1");		// remove spaces preceding ref tags and templates
//	ArticleText=Regex.Replace(ArticleText, @"(?i)[ ]+(\n|\r)", "$1");	//removes multiple spaces preceding line break [disabled on 2 Dec 2013 as pointless]
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\d),&nbsp;([12]\d{3}\b)+", "$1, $2");	//removes nbsp preceding year
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\d)(?:&nbsp;| )%", "$1%");	//removes nbsp preceding '%'
	ArticleText=Regex.Replace(ArticleText, @"(?i)(&nbsp;)[ ](–|&ndash;)", "$1$2");	//Palliative for dashes script insertion of space after nbsp

	ArticleText=Regex.Replace(ArticleText, @"\b(US|UK|A(?:US|)|C(?:AN|)|NZ|HK) ([$£¥€])(\d)", "$1$2$3");
        ArticleText=Regex.Replace(ArticleText, @"\{\{AUD\}\} ?(\d+)", "A$ $1");
	ArticleText=Regex.Replace(ArticleText, @"([$£¥€]) (\d)", "$1$2");
	ArticleText=Regex.Replace(ArticleText, @"(\{\{(?:INR|Indian Rupee)\}\}|Rs\.?)(\d+)", "$1 $2");

//rem bolding from linked AND bolded terms
//	ArticleText=Regex.Replace(ArticleText, @"'''(\[\[)([^\|\]]+?\||)([^\]]+?\]\][:-–]?)'''", "$1$2$3");

//rem 'external' wiktionary links
	ArticleText=Regex.Replace(ArticleText, @"(?i)\[https?:\/\/en\.wiktionary\.org\/wiki\/[\w]*[ ](\w[^\]]*)\]", "$1");

//rem linked copyright symbol
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[copyright\|©\]\] |©)", "");

//rem leading and lagging spaces within wikilinks
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[)[ ]+([^\[\]\|]*?)[ ]*(\]\])", "$1$2$3");
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[)[ ]*([^\[\]\|]*?)[ ]+(\]\])", "$1$2$3");
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[[^\[\]\|]*?[ ])[ ]+([^\[\]]*?\]\])", "$1$2");
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[[^\[\]\|]*?)[ ]+\|[ ]*([^\[\]]+\]\])", "$1|$2");
//	ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[[^\[\]\|]*?)[ ]*\|[ ]+([^\[\]]+\]\])", "$1|$2"); //can't remember why we need the second (repeated) line

//symbol for 'times' and dashes
//	ArticleText=Regex.Replace(ArticleText, @"(?i)&times;", "×");
//	ArticleText=Regex.Replace(ArticleText, @"(?i)([ \.][\d]+)x([\d]+(?:\.[\d]+|)\s)", "$1&nbsp;×&nbsp;$2"); //disabling - never ending false positives
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\d) x (\d )", "$1&nbsp;×&nbsp;$2");
	ArticleText=Regex.Replace(ArticleText, @"\s(A[cglmrstu]|B[ahikrad]?|C[adeflmno]|D[bsyrsu]|E[rsu]|F[elmr]?|G[adef]|H[fgos]|I[nr]?|Kr?|L[aruv]|M[dgnot]|N[abdeiop]?|Os?|P[abdmortu]?|R[abefghnu]|S[bcegimnr]?|T[abcehilm]?|U[ub][neopst]|V|W|Xe|Yb?|Z[nr])-(Br|Cl?|F|H|I|N|O|P|Se?)\s", " $1–$2 "); //signifying chemical bonds abbrev
//	ArticleText=Regex.Replace(ArticleText, @"(?i)([^<][^!] *)--( *[^>])", "$1–$2"); //disabling - causes false positives with urls and some images
	ArticleText=Regex.Replace(ArticleText, @"(?i)&mdash;", "—");
	ArticleText=Regex.Replace(ArticleText, @"(?i)([\w\d]) — (?=[\w\d])", "$1 – ");		// tweak to avoid replacing emdashes in strings that are in non-roman unicode characters
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\D7\d7)–(\d(?:00|)\D)", "$1-$2");  //airplane model numbers taking hyphen

//inserting a white space between wikilinks to avoid errors upon unlinking
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\]\][\.,]?)(\[\[)(?!file|image)", "$1 $2");

//hash fixes
	ArticleText=Regex.Replace(ArticleText, @"(?i)([^=] )#(\d{1,3}[,\.]?\s)", "$1No. $2");

//full stop and nbsp fixes
	//degrees
	ArticleText=Regex.Replace(ArticleText, @"(Ph)(?:\.\s?|\s)(D)\.?", "$1$2");
	ArticleText=Regex.Replace(ArticleText, @"(B|M)(?:\.\s?|\s)(Arch|Comm|Ed|Eng|Sc|Tech)\.?(?=\W)", "$1$2");

	//times of day, time ranges
//	ArticleText=Regex.Replace(ArticleText, @"(?i)((?:\d?\d[:\.]\d?\d| \d?\d)&nbsp;[ap])(?:\.m\.)(?=[^\w\-])", "$1m");

//	ArticleText=Regex.Replace(ArticleText, @"(?i)(\d?\d[:\.]\d?\d| \d?\d)(?:[ ]*|&nbsp;)(?:a\.m\.|am)(?:[ ]*|&nbsp;)[-–—](?:[ ]*|&nbsp;)(\d?\d[:\.]\d?\d|\d?\d)(?:[ ]*|&nbsp;)(?:p\.m\.|pm)(?=[^\w\-])", "$1&nbsp;am&nbsp;– $2&nbsp;pm");
//	ArticleText=Regex.Replace(ArticleText, @"(?i)(\d?\d[:\.]\d?\d| \d?\d)(?:[ ]*|&nbsp;)(?:p\.m\.|pm)(?:[ ]*|&nbsp;)[-–—](?:[ ]*|&nbsp;)(\d?\d[:\.]\d?\d|\d?\d)(?:[ ]*|&nbsp;)(?:a\.m\.|am)(?=[^\w\-])", "$1&nbsp;pm&nbsp;– $2&nbsp;am");
//	ArticleText=Regex.Replace(ArticleText, @"(?i)(\d?\d[:\.]\d?\d| \d?\d)(?:[ ]*|&nbsp;)(?:a\.m\.|am)(?:[ ]*|&nbsp;)[-–—](?:[ ]*|&nbsp;)(\d?\d[:\.]\d?\d|\d?\d)(?:[ ]*|&nbsp;)(?:a\.m\.|am)(?=[^\w\-])", "$1&nbsp;am&nbsp;– $2&nbsp;am");
//	ArticleText=Regex.Replace(ArticleText, @"(?i)(\d?\d[:\.]\d?\d| \d?\d)(?:[ ]*|&nbsp;)(?:p\.m\.|pm)(?:[ ]*|&nbsp;)[-–—](?:[ ]*|&nbsp;)(\d?\d[:\.]\d?\d|\d?\d)(?:[ ]*|&nbsp;)(?:p\.m\.|pm)(?=[^\w\-])", "$1&nbsp;pm&nbsp;– $2&nbsp;pm");
//	ArticleText=Regex.Replace(ArticleText, @"(?i)(\d?\d[:\.]\d?\d| \d?\d)(?:[ ]*|&nbsp;)(?:a\.m\.|am)(?:[ ]*|&nbsp;)[-–—](?:[ ]*|&nbsp;)(noon|midnight)(?=[^\w\-])", "$1&nbsp;am&nbsp;– $2");
//	ArticleText=Regex.Replace(ArticleText, @"(?i)(\d?\d[:\.]\d?\d| \d?\d)(?:[ ]*|&nbsp;)(?:p\.m\.|pm)(?:[ ]*|&nbsp;)[-–—](?:[ ]*|&nbsp;)(noon|midnight)(?=[^\w\-])", "$1&nbsp;pm&nbsp;– $2");
//	ArticleText=Regex.Replace(ArticleText, @"(?i)\b(\d?\d[:\.]\d?\d| \d?\d)(?:[ ]*|&nbsp;)(?:a\.m\.|am)(?=[^\w\-])", "$1&nbsp;am");
//	ArticleText=Regex.Replace(ArticleText, @"(?i)\b(\d?\d[:\.]\d?\d| \d?\d)(?:[ ]*|&nbsp;)(?:p\.m\.|pm)(?=[^\w\-])", "$1&nbsp;pm");

	ArticleText=Regex.Replace(ArticleText, @"(\d\.\d?\d| \d{1,3}| \d{1,3},\d{3})[ ]*(?:kw)\b", "$1&nbsp;kW");
	ArticleText=Regex.Replace(ArticleText, @"(\d\.\d?\d| \d{1,3}| \d{1,3},\d{3})[ ]*(?:khz)\b", "$1&nbsp;kHz");
	ArticleText=Regex.Replace(ArticleText, @"(\d\.\d?\d| \d{1,3}| \d{1,3},\d{3})[ ]*(?:m[Hh]z)\b", "$1&nbsp;MHz");
	ArticleText=Regex.Replace(ArticleText, @"(\d\.\d?\d| \d{1,3}| \d{1,3},\d{3})[ ]*(?:g[Hh]z)\b", "$1&nbsp;GHz");
	ArticleText=Regex.Replace(ArticleText, @"(\d\.\d?\d| \d{1,3}| \d{1,3},\d{3})[ ]*(?:kph|kphr|kmh|kmhr|kmph|kmphr|km\/hr)\b", "$1&nbsp;km/h");
	ArticleText=Regex.Replace(ArticleText, @"(\d\.\d?\d| \d{1,3}| \d{1,3},\d{3})[ ]*(?:m\.p\.h\.)\b", "$1&nbsp;mph");
	ArticleText=Regex.Replace(ArticleText, @"(\d\.\d?\d| \d{1,3}| \d{1,3},\d{3})[ ]*(gm|kg|km)s?\b", "$1&nbsp;$2");
	ArticleText=Regex.Replace(ArticleText, @"(\d\.\d?\d| \d{1,3}| \d{1,3},\d{3})[ ]*KMs?\b", "$1&nbsp;km");
	ArticleText=Regex.Replace(ArticleText, @"(\d\.\d?\d| \d{1,3}| \d{1,3},\d{3})[ ]*KGs?\b", "$1&nbsp;kg");
	ArticleText=Regex.Replace(ArticleText, @"(\d\.\d?\d| \d{1,3}| \d{1,3},\d{3})[ ]*(?:K(g|m))s?\b", "$1&nbsp;k$2");
	ArticleText=Regex.Replace(ArticleText, @"(\d\.\d?\d| \d{1,3}| \d{1,3},\d{3})[ ]*cms?", "$1&nbsp;cm");
//	ArticleText=Regex.Replace(ArticleText, @"([^\|\[=]\d{1,3})\s(m|b|tr)illion(\b[^}])", "$1&nbsp;$2illion$3");

//turn letter 'x' into symbol '×'
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\d)\sx\s(\d{1,3})\sin\s\(", "$1 × $2 in (");
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\d)\sx\s(\d{1,3})\sinch\s", "$1 × $2 inch ");

// Convert degree symbols into ° symbol, ensure preceding space
	ArticleText=Regex.Replace(ArticleText, @"&deg;", "°");
//	ArticleText=Regex.Replace(ArticleText, @"º", "°");

// Celsius spelling errors
	ArticleText=Regex.Replace(ArticleText, @"(?i)(?:celsius|celcius|centigrade)", "Celsius");

//Fix common naming error (be careful with this one)
//	ArticleText=Regex.Replace(ArticleText, @"(?i)centigrade", "Celsius");
//Celsius or Fahrenheit
	ArticleText=Regex.Replace(ArticleText, @"(\d)&nbsp;(?:[°º]|deg|degree|degrees)&nbsp;([CF]\W)", "$1&nbsp;°$2");
	ArticleText=Regex.Replace(ArticleText, @"(\d)(?:[°º]|deg|degree|degrees)&nbsp;([CF]\W)", "$1&nbsp;°$2");
	ArticleText=Regex.Replace(ArticleText, @"(\d)&nbsp;(?:[°º]|deg|degree|degrees)([CF]\W)", "$1&nbsp;°$2");
	ArticleText=Regex.Replace(ArticleText, @"(\d)(?:\s|)(?:[°º]|deg|degree|degrees)(?:\s|)([CF]\W)", "$1&nbsp;°$2");
	ArticleText=Regex.Replace(ArticleText, @"(\d)(?:\s|&nbsp;)?(?=\[\[Celsius\|[°º]C\]\])", "$1&nbsp;$2");
	ArticleText=Regex.Replace(ArticleText, @"(\d)(?:\s|&nbsp;)?(?=\[\[Fahrenheit\|[°º]F\]\])", "$1&nbsp;$2");
	ArticleText=Regex.Replace(ArticleText, @"([^\d\(\)\/\\]\s)(-?\d[\d,\.]*)(?:\s|-|&nbsp;|)[°º]F([:;,\.?!]?\s[^\d\(\)\/\\])", "$1{{convert|$2|°F|°C|abbr=on}}$3");
	ArticleText=Regex.Replace(ArticleText, @"([^\d\(\)\/\\]\s)(-?\d[\d,\.]*)(?:\s|-|&nbsp;|)(?:deg|degree|degrees)(?:\s|-|&nbsp;|)Fahrenheit([:;,\.?!]?\s[^\d\(\)\/\\])", "$1{{convert|$2|°F|°C}}$3");

// Convert &sup to superscript
//	ArticleText=Regex.Replace(ArticleText, @"(?i)(m)(?:&sup2;|²);", "$1<sup>2</sup>");
//	ArticleText=Regex.Replace(ArticleText, @"(?i)(m)(?:&sup3;|³);", "$1<sup>3</sup>");

//remove commas from numerical values in convert template
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\{convert\|\d+),(\d)", "$1$2");
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\{convert\|\d+),(\d)", "$1$2");
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\{convert\|\d+),(\d)", "$1$2");
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\{convert\|\d+),(\d)", "$1$2");
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\{convert\|\d+),(\d)", "$1$2");

//remove leading zeros from convert template
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\{\{convert\s*\|)\s*0+(?=[1-9])", "$1$2");

///per WP:COMMONALITY
	ArticleText=Regex.Replace(ArticleText, @"(?i)([Ff])reshman (year)", "$1irst $2");
	ArticleText=Regex.Replace(ArticleText, @"(?i)([Ss])ophomore (album|year)", "$1econd $2");

//Currency notation placements  [$£₤¥€]
	ArticleText=Regex.Replace(ArticleText, @"(?i)\s(\$(?:\d+\.\d\d?|\d{1,3}|\d{1,3},\d{3}))((?:\s|&nbsp;)(?:m|b|tr)illion|)[ ]*(?:US(?:[D$]|\s?dollars?))\b", " US$1$2");

//Remove surprise or 'Easter egg' diversions linking unit name to orders of magnitude articles
	ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[1\s?_?E\s?[\-\+]?\d{1,2}\s?..?\|([^\]]{1,50})\]\]", "$1");
	ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[Orders\sof\smagnitude\s\([^\)]+\)\|([^\]]{1,50})\]\]", "$1");

//remove useless comments
	ArticleText=Regex.Replace(ArticleText, @"<!-- Metadata: see \[\[Wikipedia:Persondata\]\]\. -->", "");
	ArticleText=Regex.Replace(ArticleText, @"<!-- Deleted image removed:[^>]*? -->\n*", "");
	ArticleText=Regex.Replace(ArticleText, @"<!--DASHBot-->(?=\|)", "");

///dashes
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\|(?:1[89]|20)\d{2})-(\d{2}\]\])", "$1–$2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[1[89]\d{2})-(\d{2}\D)", "$1–$2");
  ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[20[01]\d)-([012]\d\D)", "$1–$2");

//From Sources.js  [function Ohc_sources_prep]

// removing references to other WP articles and 'external' WP links
	ArticleText=Regex.Replace(ArticleText, @"(?i)<ref>https?:\/\/(?:en\.wikipedia\.org\/wiki|\w*\.(?:facebook|myspace|twitter)\.com)\/[^\s\]<]*<\/ref>", "");
	ArticleText=Regex.Replace(ArticleText, @"(?i)<ref>\[https?:\/\/(?:en\.wikipedia\.org\/wiki|\w*\.(?:facebook|myspace|twitter)\.com)\/[^\s\]]*[ ]+[\w\d][^\]]*\]<\/ref>", "");
	ArticleText=Regex.Replace(ArticleText, @"(?i)\|[ ]*url[ ]*=[ ]*https?:\/\/(?:\w{2}\.wikipedia\.org\/wiki|\w*\.(?:facebook|myspace|twitter)\.com)[^\s\|\{\}<]*(?=[ ]*[\|\}])", "");
	ArticleText=Regex.Replace(ArticleText, @"(?i)<ref[^\<>]*>[^\<>]*\|[ ]*url ?=https?:\/\/(?:\w{2}\.wikipedia\.org\/wiki|\w*\.(?:facebook|myspace|twitter)\.com)\/[^<>]*<\/ref>", "");
	ArticleText=Regex.Replace(ArticleText, @"(?i)[ ]\[https?:\/\/en\.wikipedia\.org\/wiki\/[^\s\]]*[ ]+([\w][^\]]*)\]", " [[$1]]");

// removing external links within publisher/journal/work fields
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\|\s?(?:newspaper|work|journal|publisher)\s*\=\s*)\[https?:\/\/[^\s\]]*\s([\w\d][^\]]*)\]", "$1$2");
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\|\s?author(?:link\d?|)\s*\=\s*)\[https?:\/\/[^\s\]]*\s([\w\d][^\]]*)\]", "$1$2");
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\|\s?(?:newspaper|work|journal|publisher|author)\s*\=\s*)www\.([\w\d][^\|\}]*)(?=[\|\}])", "$1$2");
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\|\s?author(?:link\d?|)\s*\=\s*)www\.([\w\d][^\|\}]*)(?=[\|\}])", "$1$2");

	ArticleText=Regex.Replace(ArticleText, @"(?i)(\|\s?author\s*\=\s*)(?:by |)(?:wire staff|staff reporters?|)[ ]*(?=[\|\}])", "");
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\|\s?author\s*\=\s*)([A-Z][a-z]*(?: [A-Z][a-z]*)*) (?:wire staff|(?:staff |)reporters?)[ ]*(?=[\|\}])", "$1$2");
    ArticleText=Regex.Replace(ArticleText, @"(?i)\|[ ]*last=Reporter[ ]*\|[ ]*first=[^\|\{\}]*(?=[\|{}])=", "");

	ArticleText=Regex.Replace(ArticleText, @"(?i)\{\{wikinews ?(|2|cat(?:egory)?|has|par2?|portal|table|-inline)(\|[^\}]+|)\}\}\s*", "");
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\*[ ]*|)\[\[n:[^\]]*\]\][^\r\n]*[\r\n]", "");
	ArticleText=Regex.Replace(ArticleText, @"(?i)\*[ ]*\{\{(?:Facebook|Find a Grave|Myspace)\|([^}]*)\}\}[\n\r\s]*", "");

//citation template fixes
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\|\s?)published\s?=", "$1publisher=");
    // rem copyright assertion
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\|\s?publisher\s*\=\s*)(?:\[\[copyright(?:\|©|)\]\])\s?", "$1");
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\|\s?publisher\s*\=\s*)(?:©|copyright)\s?", "$1");
    // misused 'date' parameter - part of AWB general fixes
//	ArticleText=Regex.Replace(ArticleText, @"(?i)\|\s?date(\s*=\s*[12]\d{3}\s?[\|\}])", "|year$1");
    // rem toggles and redundant quote marks
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\|\s?(?:agency|author|newspaper|work|journal|publisher)\s*\=\s*)\'\'([^\|\}]+)\'\'(?=\s*[\}\|])", "$1$2"); //without link
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\|\s?(?:agency|author|newspaper|work|journal|publisher)\s*\=\s*)\'\'(\[\[(?:[^\|]+\||)[^\|\]]+\]\])\'\'(?=\s*[\}\|])", "$1$2");  //with link
    ArticleText=Regex.Replace(ArticleText, @"(?i)(\|\s?title\s*\=\s*)\'&#39;([^\|\{\}]+)\'&#39;", "$1$2"); //rem &#39; in titles

// Italicising journals
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\|\s*)publisher(\s*=\s*(?:\[\[|)(?:Billboard|Empire|Kerrang|Mixmag|Mojo|NME))(?:\.com|\.co\.uk|) ?(?=[\]|}\n])", "$1work$2");
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\|\s*)publisher(\s*=\s*(?:\[\[|)(?:The ?|)(?:\w+ |)*(?:Economist|Gazette|Guardian|Herald|Independent|Mail|Mirror|Post|Standard|Star|Telegraph|Times))(?:\.com|\.co\.uk|) ?(?=[\]|}\n])", "$1work$2");
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\|\s*)publisher(\s*=\s*(?:\[\[|)(?:The ?|)(?:Hindustan Times|The ?Hindu|Times ?of ?India|Deccan ?Chronicle|Indian ?Express|Economic ?Times|NME))(?:\.com|\.co\.uk|) ?(?=[\]|}\n])", "$1work$2");

    // rem corporate designation
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\|\s?publisher\s*\=\s*[^\[\|\}]{1,40}), (?:Inc|LL[CP]|Ltd|PLC|SA)\.?(?=[ ]*\|\})", "$1");
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\|\s?publisher\s*\=\s*[^\[\|\}]{1,40}) (?:Inc|LL[CP]|Ltd|PLC|SA)\.?(?=[ ]*\|\})", "$1");

    // rem unnecessary quote marks
//	ArticleText=Regex.Replace(ArticleText, @"(?i)(\|\s?title\s*\=\s*)[""“"]([^\|]+)[""”"](?=\s?[\|\}])", "$1$2");
        ArticleText=Regex.Replace(ArticleText, @"(?i)(\|\s?title\s*\=\s*)['‘]([^\|'’]+)['’](?=\s?[\|\}])", "$1$2");
    // repl double 'in-title' quote marks with single quotes
//	ArticleText=Regex.Replace(ArticleText, @"(?i)(\|\s?title\s*\=\s*[\w ]* )[""“"]((?:\w[\w]* )+(?:\w[\w]*))[""”"]([^\|]+|)(?=\s?[\|\}])", "$1\'$2\'$3");

    // rem misplaced punctuation
         ArticleText=Regex.Replace(ArticleText, @"(?i)(<ref[^>]*>[^<]+?[\]\.\},;–]\s*\'\'[\w-]*(?: [\w-]*){0,3})(\.com|)([;,\.])(\'\')([^<]*?<\/ref>)", "$1$2$4$3$5");
//	ArticleText=Regex.Replace(ArticleText, @"(?i)([\w]+)\.(['"""]\]?)(\W)", "$1$2.$3");    //LQ for titles

    // removing blank parameters
         ArticleText=Regex.Replace(ArticleText, @"(?i)(?:\|[ ]*(?:accessdate|agency|archive(?:date|url)|arxiv|asin|at|author(-?link|-mask|-name-separator|-separator|\d|\d-link|link\d?|)|bibcode|chapter|chapter-url|coauthors|contribution(?:-url|)|date|deadurl|display-authors|doi|doi-inactive|doibroken|edition|editor(?:-first|-last|-link|\d|\d-first|\d-last|\d-link|)|(?:first|last)\d?|format|id|is[bs]n|issue|jfm|journal|jstor|language|lay(?:date|source|summary)|lccn|location|magazine|month|mr|newspaper|nopp|oclc|ol|origyear|osti|others|pages?|periodical|place|pm[cd]|pmid|postscript|publication(?:-date|-place)|publisher|quote|ref|rfc|separator|series|ssrn|trans_title|type|url|volume|work|year|zbl)[ ]*=[\s]*)(?=[\}\|])", "");

    //rem underlining within certain fields
	ArticleText=Regex.Replace(ArticleText, @"(?i)(\|\s?(?:journal|newspaper|periodical|publisher|work)\s*\=\s*)<u>([^\|\}]*)<\/u>", "$1");

    //rem redundant top-level domains (.com, .net, .org)
    ArticleText=Regex.Replace(ArticleText, @"(?i)(\|\s?(?:journal|newspaper|periodical|publisher|work)\s*\=\s*)(\[\[[^\[\]\}]*\]\])\.(?:biz|com|net|org|co\.uk)(?=\s*[\|\}])", "$1$2");

    //rem duplicated publishers in separate fields (pre)
         ArticleText=Regex.Replace(ArticleText, @"(?i)[‒–—―]+\s*([^\|\}]{3,})\s*(\|\s?(?:publisher|work)\s*\=\s*(?:\w+\.|))\1(?=\s[\|\}])", "$2$1");
    //'work' and its alias (pre)
         ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*?newspaper[ ]*=[^\|]*(?:\|[^\{\}]*|))(?:\|[ ]*?work[ ]*=[^\|\}]*)(?=[\|\}])+", "$1");

    //rem linking within locations field
         ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*?location=[ ]*?)\[\[([^\|\]]+?)\]\](?:(,? )\[\[([^\|\]]+?)\]\]|)([ ]{0,1})", "$1$2$3$4$5");
         ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*?location=[ ]*?)\[\[(?:[^\|\]]+?\|)([\w\s\,]+?)\]\](?:(,? )\[\[([^\|\]]+?)\]\]|)([ ]{0,1})", "$1$2$3$4$5");

// removing english icon template
    ArticleText=Regex.Replace(ArticleText, @"(?i)[ ]?\{\{en[- ]icon\}\}", "");

// removing icon template from within "|language=" parameter
    ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*?language[ ]*?=[ ]*?)\{\{(\w{2})[- ]icon\}\}", "$1$2");

// eliminating time of day
    ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*author[ ]*=[ ]*)(?:posted|published)(?: by| on|)[\s:](?=\s*\w)", "$1");
    ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*author[ ]*=[ ]*)[123]?\d (Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?) (?:(?:18|19|20|\d)\d{2})(?: at| on)", "$1");
    ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*author[ ]*=[ ]*)[123]?\d (Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?) (?:(?:18|19|20|\d)\d{2})", "$1");
    ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:date|archivedate|accessdate|author)[ ]*=[ ]*)[0-2]?\d:[0-5]\d(?:[ ]|&nbsp;)(?:[ap]m ?|[ap]\.m\. |[A-Z]{1,2}T|UTC)[\.,]?[ ]?", "$1");

    // eliminating days of the week
    ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:date|archivedate|accessdate|author)[ ]*=[ ]*)(?:(?:Mon|Tues|Wednes|Thurs|Fri|Satur|Sun)day,?)\s", "$1");
    ArticleText=Regex.Replace(ArticleText, @"(?i)(\|[ ]*(?:date|archivedate|accessdate|author)[ ]*=[ ]*)(?:(?:Mon|Tues?|Wed|Thur?|Fri|Sat|Sun)[\.,]?)\s", "$1");


return ht.AddBack(ArticleText);

return ArticleText;
}