User:Lightmouse/AWB/scripts/delink to mdy
Appearance
//delink to mdy
//
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)?)\|(\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$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|)\|(\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$2]]");
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)?)\|(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$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|)\|(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$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");
//remove leading zeros from dts templates
ArticleText=Regex.Replace(ArticleText, @"(?i)({{dts\d?\|[^}]*\|)0([^}]*}})", "$1$2");
//delink ISO dates
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(\d{4}-\d\d-\d\d)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(\d{4})\]\]-\[\[(\d\d-\d\d)\]\]", "$1-$2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\d{4})-\[\[(\d\d-\d\d)\]\]", "$1-$2");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(\d{4})\]\]-(\d\d-\d\d)", "$1-$2");
//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(?: |-)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");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(\d{1,2}(?:st|nd|rd|th)(?: |-))century\]\]", "$1century");
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))\]\]", "$1");
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, @"(?i)\[\[(\d{1,4})\'?s\]\]", "$1s");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(\d{1,4})\'?(s)? (AD|BC|CE|BCE)\]\]", "$1$2 $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[\d{1,4}\'?s? (?:AD|BC|CE|BCE)\|(\d{1,4})\'?(s)?\]\]", "$1$2");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[\d{1,4}\'?s? (?:AD|BC|CE|BCE)\|(\d{1,4})\'?(s)? (AD|BC|CE|BCE)\]\]", "$1$2 $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[\d{1,4}\'?s?\|(\d{1,4})\'?(s)? (AD|BC|CE|BCE)\]\]", "$1$2 $3");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[\d{1,4}\'?s?\|(\d{1,4})\'?(s)?\]\]", "$1$2");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[\d\d?(?:st|nd|rd|th) centur(?:y|ies)\|(\d{1,4})\'?(s)?\]\]", "$1$2");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[\w{5,12} centur(?:y|ies)\|(\d{1,4})\'?(s)?\]\]", "$1$2");
//solitary day_numbers
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)\[\[(\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}#[^\|\]]+\|((?:January|February|March|April|May|June|July|August|September|October|November|December) \d{3,4})\]\]", "[[$1]]");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December) \d{3,4})\]\]", "$1");
//removed piped years when in full date
ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[\d{1,2} (?:January|February|March|April|May|June|July|August|September|October|November|December)\]\],? ?\[\[)[^\|\]]{1,32}\|(\d{1,4}\]\])", "$1$2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \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)\|(January|February|March|April|May|June|July|August|September|October|November|December)\]\]", "$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)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\|(\d{1,4})\]\]", "$1");
//Month+day_number "March 7th" -> "March 7"
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(January|February|March|April|May|June|July|August|September|October|November|December) (\d?\d)(?:th|st|nd|rd)\]\]", "[[$1 $2]]");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December) \d?\d)\]\](?:th|st|nd|rd)", "[[$1]]");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(\d?\d)(?:th|st|nd|rd) (January|February|March|April|May|June|July|August|September|October|November|December)\]\]", "[[$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) (?: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))\]\]", "$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)\|(\d{1,2}(?:th|st|nd|rd) (?:January|February|March|April|May|June|July|August|September|October|November|December))\]\]", "$1");
//days of the week in full. Optional plurals
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(Mondays?|Tuesdays?|Wednesdays?|Thursdays?|Fridays?|Saturdays?|Sundays?)\]\]", "$1");
//days of the week abbreviated. Leave out 'Sun' as potentially valid link to the Sun. Leave out 'SAT' in upper case as potential link to 'Scholastic achievement/aptitude test'.
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(Mon|Tue|Tues|Wed|Thu|Thur|Thurs|Fri)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(Sat)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[Mondays?\|(Mondays?|Mon)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[Tuesdays?\|(Tuesdays?|Tues?)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[Wednesdays?\|(Wednesdays?|Wed)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[Thursdays?\|(Thursdays?|Thur?)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[Fridays?\|(Fridays?|Fri)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[Saturdays?\|(Saturdays?|Sat)\]\]", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[Sundays?\|(Sundays?|Sun)\]\]", "$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) (?:[0-3][\d]|[\d])\]\]), \[\[(\d{1,4}) in [^\]]{1,32}\]\]", "$1 $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[(?:[0-3][\d]|[\d]) (?:January|February|March|April|May|June|July|August|September|October|November|December)\]\]) \[\[(\d{1,4}) in [^\]]{1,32}\]\]", "$1 $2");
ArticleText=Regex.Replace(ArticleText, @"(?i)(\[\[(?:[0-3][\d]|[\d]) (?:January|February|March|April|May|June|July|August|September|October|November|December)\]\]) {{(?: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) (?:[0-3][\d]|[\d])\]\]), {{(?: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(\d)(?:th|st|nd|rd|)\]\]", "[[$1 $2]]");
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[0(\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]]");
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})\]\]", "$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\d])", "$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");
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})\]\]", "$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\d])", "$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");
//year: temporary change to protect accessyear. Undone below at #1
ArticleText=Regex.Replace(ArticleText, @"(?i)(accessyear\s?=\s?)\[\[(\d{1,4})\]\]", "$1xx$2xx");
//year: now remove unprotected linked years
ArticleText=Regex.Replace(ArticleText, @"(?i)\[\[(\d{1,4})\]\]", "$1");
//year: #1. Undo temporary change to protect accessyear and date preference dates
ArticleText=Regex.Replace(ArticleText, @"(?i)xx(\d{1,4})xx", "[[$1]]");
//remove dts-simple template that links dates
ArticleText=Regex.Replace(ArticleText, @"(?i){{dts-simple\|(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\|\s?(\d\d?)\|(\d{1,4})}}", "$1 $2, $3");
//remove dts3 template that links dates
ArticleText=Regex.Replace(ArticleText, @"(?i){{dts3\|(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,4})}}", "$1 $2, $3");
//change deprecated dts2 template
ArticleText=Regex.Replace(ArticleText, @"(?i){{dts2\|(.*?)\|(.*?)\|(.*?)}}", "{{dts|link=off|$3|$2|$1}}");
//fix dts template
ArticleText=Regex.Replace(ArticleText, @"(?i)({{dts\|)", "$1link=off|");
ArticleText=Regex.Replace(ArticleText, @"(?i)({{dts\|)link=off\|([^}]*link=off)", "$1$2");
//change deprecated birth and death templates
ArticleText=Regex.Replace(ArticleText, @"(?i)({{(?:Birth|Death|release)[^}]*)\|df=ye?s?", "$1");
ArticleText=Regex.Replace(ArticleText, @"(?i)({{(?:Birth|Death|release)[^|]*\|)", "$1mf=yes|");
ArticleText=Regex.Replace(ArticleText, @"(?i)({{(?:Birth|Death|release)[^|]*\|)mf=ye?s?\|([^}]*mf=ye?s?)", "$1$2");
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;
}
//