Jump to content

User:Lightmouse/AWB/scripts/delink nonfull dates

From Wikipedia, the free encyclopedia

//delink nonfull dates

//

        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);

//protect certain dates
ArticleText=Regex.Replace(ArticleText, @"(?i)(september) (11[^\d])", "$1xx$2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[september)xx(11\]\])", "$1 $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[september)xx(11, 2001 attacks\]\])", "$1 $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)([^\d]7) (july)", "$1xx$2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[7)xx(july\]\])", "$1 $2");

ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[\d{1,2}(?: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,30})\]\]", "$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)?) \d{1,2}(?:th|st|nd|rd|)\|([^\]]{1,30})\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[\d{1,2} (?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\|([^\]]{1,30})\]\]", "$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)?) \d{1,2}(?:th|st|nd|rd|)\|([^\]]{1,30})\]\]", "$1$2");

//month+day piped to number
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[\d{1,2}(?: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)?)\|(\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)?) \d{1,2}(?:th|st|nd|rd|)\|(\d{1,4})\]\]", "[[$1]]");

//fix 'bda' template redirect
ArticleText=Regex.Replace(ArticleText, @"(?i){{bda\|([^}]+)}}", "{{birth date and age|$1}}");

ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[) ([^\]]*\]\])", "$1$2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[[^\]\|]*) (\]\])", "$1$2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[[^\]]* ) +([^\]]\]\])", "$1$2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[[^\]]*\d),(\]\])", "$1$2");

//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(?: |-)first)(?: |-))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(?: |-)first)(?: |-))century (AD|BC|CE|BCE)\]\]", "$1century $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(\d{1,2}(?:st|nd|rd|th)(?: |-))(century|centuries)\]\]", "$1$2");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[\d{1,2}(?:st|nd|rd|th)(?: |-)century\|([^\]]{1,32})\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[\w{5,12} centur(?:y|ies)\|(\d{1,4})\'?(s)?\]\]", "$1$2");

//ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(\d{1,2}(?:st|nd|rd|th)(?: |-))centuries\]\]", "$1centuries");
//ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[\d{1,2}(?:st|nd|rd|th)(?: |-)century\|(\d{1,2}(?:st|nd|rd|th)(?: |-))century\]\]", "$1century");
//ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[\d{1,2}(?:st|nd|rd|th)(?: |-)century\|(\d{1,2}(?:st|nd|rd|th)(?: |-))centuries\]\]", "$1centuries");
//ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(\d{1,2}(?:st|nd|rd|th)(?: |-))century (AD|BC|CE|BCE)\]\]", "$1century $2");
//ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[\d{1,2}(?:st|nd|rd|th)(?: |-)century\|(\d{1,2}(?:st|nd|rd|th)(?: |-))century (AD|BC|CE|BCE)\]\]", "$1century $2");
//ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[\d{1,2}(?:st|nd|rd|th)(?: |-)century\|(\d{1,2}(?:st|nd|rd|th)(?: |-))centuries (AD|BC|CE|BCE)\]\]", "$1centuries $2");

//Protect 2000 AD etc
ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[(?:2300|2000)) (AD\]\])", "$1xx$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");

//solitary day_numbers
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)?) \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) (?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\|(\d{1,2}(?:th|st|nd|rd))\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(\d{1,2}(?:st|nd|rd|th))\]\]", "$1");

//Unprotect 2000 AD etc
ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[(?:2300|2000))xx(AD]\])", "$1 $2");

//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}#[^\|\]]+\|((?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?) \d{3,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)?) \d{3,4})\]\]", "$1");

//removed piped years when in full date
ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[\d{1,2} (?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\]\],? ?\[\[)[^\|\]]{1,32}\|(\d{1,4}\]\])", "$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)?) \d{1,2}\]\],? ?\[\[)[^\|\]]{1,32}\|(\d{1,4}\]\])", "$1$2");

//remove 'xx' left by other code
ArticleText=Regex.Replace(ArticleText, @"(?i)(in)xx((?:aviation|baseball|film|literature|comics|ireland))", "$1 $2");

//'present'
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[Present \(time\)\|(Present)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(Present)\]\]", "$1");

//Season
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(spring \(season\)|summer|winter|autumn)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[spring \(season\)\|(spring)\]\]", "$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");

//months
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[ ?(January|February|March|April|May|June|July|August|September|October|November|December) ?\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"\[\[(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\|([^\]]{1,30})\]\]", "$1");
//Treat 'Sept' (i.e. month abbreviation) differently from 'sept' (i.e. family)
ArticleText=Regex.Replace(ArticleText, @"\[\[(Sept)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[January\|(Jan)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[February\|(Feb)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[March\|(Mar)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[April\|(Apr)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[May\|(May)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[June\|(Jun)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[July\|(Jul)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[August\|(Aug)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[September\|(Sep)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[October\|(Oct)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[November\|(Nov)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[December\|(Dec)\]\]", "$1");

//month piped to number
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)?)\|(\d{1,4})\]\]", "$1");

//Month+day_number "March 7th" -> "March 7"
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)?) (\d?\d)(?: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)?) \d?\d)\]\](?:th|st|nd|rd)", "[[$1]]");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(\d?\d)(?: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]]");

//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) \d?\d)\]\]( ?\-? ?)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \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) \d?\d)\]\]( ?&[nm]dash; ?)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \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) \d?\d)\]\](\/)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \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) \d?\d)\]\]( ?\-? ?)\[\[(\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) \d?\d)\]\]( ?&[nm]dash; ?)\[\[(\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) \d?\d)\]\](\/)\[\[(\d{1,2}(?:th|st|nd|rd))\]\]", "$1$2$3$4");

ArticleText=Regex.Replace(ArticleText, @"(?i)([^\[]{4})\[\[(\d?\d) (?:January|February|March|April|May|June|July|August|September|October|November|December)\]\]( ?\-? ?)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \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) (?:January|February|March|April|May|June|July|August|September|October|November|December)\]\]( ?&[nm]dash; ?)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \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) (?:January|February|March|April|May|June|July|August|September|October|November|December)\]\](\/)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \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) (?:January|February|March|April|May|June|July|August|September|October|November|December)\]\]( ?\-? ?)\[\[(\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) (?:January|February|March|April|May|June|July|August|September|October|November|December)\]\]( ?&[nm]dash; ?)\[\[(\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) (?: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) \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) (?: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)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}(?:th|st|nd|rd)\|((?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \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) (?: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)?) \d{1,2}(?:th|st|nd|rd))\]\]", "$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)?) \d{1,2}(?:th|st|nd|rd)\|(\d{1,2}(?: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");

//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)(\[\[(?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?) (?:[0-3][\d]|[\d])\]\]), \[\[(\d{1,4}) in [^\]]{1,32}\]\]", "$1 $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[(?:[0-3][\d]|[\d]) (?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\]\]) \[\[(\d{1,4}) in [^\]]{1,32}\]\]", "$1 $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[(?:[0-3][\d]|[\d]) (?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\]\]) {{(?:avyear|by|fy|ly|scy|sdy)\|(\d{1,4})}}", "$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)?) (?:[0-3][\d]|[\d])\]\]), {{(?:avyear|by|fy|ly|scy|sdy)\|(\d{1,4})}}", "$1 [[$2]]");


//year: temporary change to protect accessyear. Undone below at #1
ArticleText=Regex.Replace(ArticleText, @"(?i)(accessyear ?= ?)\[\[(\d{1,4})\]\]", "$1xx$2xx");

//Year: temporary change to protext preference dates. Needed to handle 'year in' piped links
            ArticleText = Regex.Replace(ArticleText, @"(?i)(\[\[\d\d? (?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\]\],? ? ?)\[\[((?:\d{1,3}|[12]\d{3}))\]\]",  "$1xx$2xx");
            ArticleText = Regex.Replace(ArticleText, @"(?i)(\[\[\d\d? (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\]\],? ? ?)\[\[((?:\d{1,3}|[12]\d{3}))\]\]",  "$1xx$2xx");
            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)?) \d\d?\]\],? ? ?)\[\[((?:\d{1,3}|[12]\d{3}))\]\]",  "$1xx$2xx");
            ArticleText = Regex.Replace(ArticleText, @"(?i)(\[\[(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d\d?\]\],? ? ?)\[\[((?:\d{1,3}|[12]\d{3}))\]\]",  "$1xx$2xx");
            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[((?:\d{1,3}|[12]\d{3}))\]\](,? ?\-? ?\[\[(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d\d?\]\])",  "xx$1xx$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[((?:\d{1,3}|[12]\d{3}))\]\](,? ?\-? ?\[\[(?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?) \d\d?\]\])",  "xx$1xx$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[((?:\d{1,3}|[12]\d{3}))\]\](,? ?\-? ?\[\[\d\d? (?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\]\])",  "xx$1xx$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[((?:\d{1,3}|[12]\d{3}))\]\](,? ?\-? ?\[\[\d\d\-\d\d\]\])",  "xx$1xx$2");

//year: now remove unprotected linked years
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(\d{1,4})\]\]", "$1");
//year: Undo temporary change to protect accessyear and date preference dates
ArticleText=Regex.Replace(ArticleText, @"(?i)xx(\d{1,4})xx", "[[$1]]");
//year: Undo temporary change to protect accessyear and date preference dates
            ArticleText = Regex.Replace(ArticleText, @"(?i)xx((?:\d{1,3}|[12]\d{3}))xx", "[[$1]]");



ArticleText=Regex.Replace(ArticleText, @"(?i)(september)xx(11)", "$1 $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(7)xx(july)", "$1 $2");


return ht.AddBack(ArticleText);

return ArticleText;
}
//