User:Milk's Favorite Cookie/javascript conversion

From Wikipedia, the free encyclopedia

//Script originally by [[User:Lightmouse]]
//Original version is available at [[User:Lightmouse/javascript conversion]]
        public string ProcessArticle(string ArticleText, string ArticleTitle, int wikiNamespace, out string Summary, out bool Skip)
        {
            Skip = false;
            Summary = "";
//Identify surprise or 'Easter egg' diversions linking years to 'year in something' articles. Turn them into year links to be dealt with below
//removed
 
// 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");
 
// decades and years
            ArticleText = Regex.Replace(ArticleText, @"\[\[(\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, @"\[\[\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}\|(\d{1,2}(?:st|nd|rd|th))\]\]", "$1");
            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[\d{1,2} (?:January|February|March|April|May|June|July|August|September|October|November|December)\|(\d{1,2}(?:st|nd|rd|th))\]\]", "$1");
            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(\d{1,2}(?:st|nd|rd|th))\]\]", "$1");
 
//month+day: removed.
 
//Identify surprise or 'Easter egg' diversions linking month+years to year articles. Turn them into month+year links to be dealt with below
//removed
 
//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)(?:st|nd|rd|th)\]\]", "[[$1 $2]]");
            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December) \d?\d)\]\](?:st|nd|rd|th)", "[[$1]]");
            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(\d?\d)(?:st|nd|rd|th) (January|February|March|April|May|June|July|August|September|October|November|December)\]\]", "[[$1 $2]]");
 
//Month + year
            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December) \d{3,4})\]\]", "$1");
            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(\d{3,4} (?:January|February|March|April|May|June|July|August|September|October|November|December))\]\]", "$1");
 
 
//remove piped years
            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[\d{1,4} in .{1,30}\|(\d{1,4})\]\]",  "[[$1]]");
 
 
//remove piped years from full dates
//            ArticleText = Regex.Replace(ArticleText, @"(?i)(\[\[\d\d? (?:January|February|March|April|May|June|July|August|September|October|November|December)\]\],? ? ?)\[\[.{1,30}\|(\d{1,4})\]\]",  "$1[[$2]]");
//            ArticleText = Regex.Replace(ArticleText, @"(?i)(\[\[\d\d? (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\]\],? ? ?)\[\[.{1,30}\|(\d{1,4})\]\]",  "$1[[$2]]");
//            ArticleText = Regex.Replace(ArticleText, @"(?i)(\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \d\d?\]\],? ? ?)\[\[.{1,30}\|(\d{1,4})\]\]",  "$1[[$2]]");
//            ArticleText = Regex.Replace(ArticleText, @"(?i)(\[\[(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d\d?\]\],? ? ?)\[\[.{1,30}\|(\d{1,4})\]\]",  "$1[[$2]]");
//            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[.{1,30}\|(\d{1,4})\]\](,? ?\-? ?\[\[(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d\d?\]\])",  "[[$1]]$2");
//            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[.{1,30}\|(\d{1,4})\]\](,? ?\-? ?\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \d\d?\]\])",  "[[$1]]$2");
//            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[.{1,30}\|(\d{1,4})\]\](,? ?\-? ?\[\[\d\d? (?:January|February|March|April|May|June|July|August|September|October|November|December)\]\])",  "[[$1]]$2");
//            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[.{1,30}\|(\d{1,4})\]\](,? ?\-? ?\[\[\d\d\-\d\d\]\])",  "[[$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}#[^\|]{1,30}\|(January|February|March|April|May|June|July|August|September|October|November|December)\]\]", "$1");
 
//'As of year'
            ArticleText = Regex.Replace(ArticleText, @"(?i)(As of )\[\[(\d{1,4})\]\]", "$1$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(As of \d{1,4})\]\]", "$1");
            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(as of \d{1,4})\]\]", "$1");
 
// months
            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(January|February|March|April|May|June|July|August|September|October|November|December)\]\]", "$1");
            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(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, @"(?i)\[\[(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 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 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}\|(\d{1,2})\]\]", "$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}\|(\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)\]\](\/)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}\|(\d{1,2})\]\]", "$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})\]\]", "$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})\]\]", "$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}\|(\d{1,2})\]\]", "$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}\|(\d{1,2})\]\]", "$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}\|(\d{1,2})\]\]", "$1$2$3$4");
 
            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}\|(\d{1,2})\]\]", "$1");
            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[\d{1,2} (?:January|February|March|April|May|June|July|August|September|October|November|December)\|(\d{1,2})\]\]", "$1");
 
            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}\|((?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{1,2})\]\]", "$1");
//month+day piped into month+day or vice versa
            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[\d{1,2} (?: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})\]\]", "$1");
            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}\|(\d{1,2} (?: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, @"\[\[(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})\]\]", "$1");
 
//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 - y?y?y?. Needed to handle 'year in' piped links
            ArticleText = Regex.Replace(ArticleText, @"(?i)(\[\[\d\d? (?:January|February|March|April|May|June|July|August|September|October|November|December)\]\],? ? ?)\[\[(\d{1,4})\]\]y?y?y?",  "$1xx$2xx");
            ArticleText = Regex.Replace(ArticleText, @"(?i)(\[\[\d\d? (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\]\],? ? ?)\[\[(\d{1,4})\]\]y?y?y?",  "$1xx$2xx");
            ArticleText = Regex.Replace(ArticleText, @"(?i)(\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \d\d?\]\],? ? ?)\[\[(\d{1,4})\]\]y?y?y?",  "$1xx$2xx");
            ArticleText = Regex.Replace(ArticleText, @"(?i)(\[\[(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d\d?\]\],? ? ?)\[\[(\d{1,4})\]\]y?y?y?",  "$1xx$2xx");
            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(\d{1,4})\]\]y?y?y?(,? ?\-? ?\[\[(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d\d?\]\])",  "xx$1xx$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(\d{1,4})\]\]y?y?y?(,? ?\-? ?\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \d\d?\]\])",  "xx$1xx$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(\d{1,4})\]\]y?y?y?(,? ?\-? ?\[\[\d\d? (?:January|February|March|April|May|June|July|August|September|October|November|December)\]\])",  "xx$1xx$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(\d{1,4})\]\]y?y?y?(,? ?\-? ?\[\[\d\d\-\d\d\]\]y?y?y?)",  "xx$1xx$2");
 
//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 flagicons from birth and death
            ArticleText = Regex.Replace(ArticleText, @"(?i)(birth ?= ?)\{\{flagicon\|[^\}]{1,30}\}\}", "$1");
            ArticleText = Regex.Replace(ArticleText, @"(?i)(death ?= ?)\{\{flagicon\|[^\}]{1,30}\}\}", "$1");
            ArticleText = Regex.Replace(ArticleText, @"(?i)(birth_?place ?= ?)\{\{flagicon\|[^\}]{1,30}\}\}", "$1");
            ArticleText = Regex.Replace(ArticleText, @"(?i)(death_?place ?= ?)\{\{flagicon\|[^\}]{1,30}\}\}", "$1");
 
            //symbol for superscript 2 and 3
            //ArticleText = Regex.Replace(ArticleText, @"(?i)<sup>2<\/sup>", "²");
            //ArticleText = Regex.Replace(ArticleText, @"(?i)<sup>3<\/sup>", "³");
 
            // Convert degree symbols into ° symbol, ensure preceding space
            ArticleText = Regex.Replace(ArticleText, @"(?i)&deg;", "°");
            ArticleText = Regex.Replace(ArticleText, @"(?i)º", "°");
 
            //aviation specifications: protect "main=" and "alt=" - undone below
            ArticleText = Regex.Replace(ArticleText, @"(?i)((?:main|alt) ?= ?)(\d)", "$1xx$2");
 
            // Celsius spelling errors
            ArticleText = Regex.Replace(ArticleText, @"(?i)celsius", "Celsius");
            ArticleText = Regex.Replace(ArticleText, @"(?i)celcius", "Celsius");
            //Fix common naming error (be careful with this one)
            ArticleText = Regex.Replace(ArticleText, @"(?i)centigrade", "Celsius");
            //Celsius or Fahrenheit
            ArticleText = Regex.Replace(ArticleText, @"(?i)(?:°|deg\.?|degrees)(?: |&nbsp;|)(C|F)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "°$1$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)(?:°|deg\.?)(?:&nbsp| |)Celsius([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "°C$1");
            ArticleText = Regex.Replace(ArticleText, @"(?i)(\d)°\[\[", "$1 °[[");
            ArticleText = Regex.Replace(ArticleText, @"(?i)(\d)(\[\[Celsius|°C\]\])", "$1 $2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)(\d)(\[\[Fahrenheit|°F\]\])", "$1 $2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(-?\d[\d,\.]{0,16})(?: |-|&nbsp;|)°F([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|°F|°C|abbr=on}}$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(-?\d[\d,\.]{0,16})(?: |-|&nbsp;|)(?:deg|degree|degrees)(?: |-|&nbsp;|)Fahrenheit([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|°F|°C}}$3");
 
            // Convert &sup to superscript
            ArticleText = Regex.Replace(ArticleText, @"(?i)&sup2;", "²");
            ArticleText = Regex.Replace(ArticleText, @"(?i)&sup3;", "³");
 
            //metre
            //delink this common unit
            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(metres|meters|metre|meter)\]\]", "$1");
            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(?:metres|meters|metre|meter)\|(m)\]\]", "$1");
            //space before "m" only when lower case. Check for dollars and pounds to avoid "m" used for millions in money.
            ArticleText = Regex.Replace(ArticleText, @"([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|)m([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 m$3");
            //convert "metres" to "m" when in parentheses
            ArticleText = Regex.Replace(ArticleText, @"(?i)(\(\d[\d,\.]{0,16})(?: |-|)(?:metres|meters|metre|meter)(\))", "$1 m$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)(\(\d[\d,\.]{0,16})&nbsp;(?:metres|meters|metre|meter)(\))", "$1&nbsp;m$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|\d{1,16}\|(?:m|ft)\|[^\}]{0,16})\|lk=(?:on|in|out)", "$1");
 
            //metre per second
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|)(?:m\/second|m\/sec)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 m/s$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})&nbsp;(?:m\/second|m\/sec)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2&nbsp;m/s$3");
 
            //square metre
            ArticleText = Regex.Replace(ArticleText, @"(?i)(\d)(?: |-|&nbsp;|)sq(?: |\. |-|&nbsp;)m([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 m²$2");
            //remove period when followed by close parenthesis character
            ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|\d{1,16}\|(?:sqm|sqft)[^\}]{0,16})\|lk=(?:on|in|out)", "$1");
 
            // millimetre
            //delink this common unit
            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(milli(?:metres|meters|metre|meter))\]\]", "$1");
            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[milli(?:metres|meters|metre|meter)\|(mm)\]\]", "$1");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|)mm([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 mm$3");
 
            // centimetre, cubic centimetre
            //delink this common unit
            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(centi(?:metres|meters|metre|meter))\]\]", "$1");
            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[centi(?:metres|meters|metre|meter)\|(cm)\]\]", "$1");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|)(cm|cc)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 $3$4");
 
            // kilometre
            //delink this common unit
            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(kilo(?:metres|meters|metre|meter))\]\]", "$1");
            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[kilo(?:metres|meters|metre|meter)\|(km)\]\]", "$1");
            //delink this common unit
            ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|\d{1,16}\|(?:mi|km)[^\}]{0,16})\|lk=(?:on|in|out)", "$1");
 
            //square kilometre
            //delink this common unit
            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(km²)\]\]", "$1");
            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[square kilomet..\|(km²)\]\]", "$1");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\|])sq\.?(?: |-|&nbsp;|)kms?", "$1km²");
            ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|\d{1,16})00\|ha", "$1|km2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|\d{1,16})(\d)0\|ha", "$1.$2|km2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|\d{1,16})(\d\d)\|ha", "$1.$2|km2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|\d{1,16}\|sqmi\|)ha", "$1km2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|\d{1,16}\|mi2\|)ha", "$1km2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|\d{1,16}\|(?:sqkm|sqmi|km2|mi2)[^\}]{0,16})\|lk=(?:on|in|out)", "$1");
            ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|\d{3,16}\|acre\|)ha", "$1km2");
 
            //kilometre per second
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|)(?:km\/second|km\/sec)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 km/s$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})&nbsp;(?:km\/second|km\/sec)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2&nbsp;km/s$3");
 
            // kilometre per hour
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|)(?:km\/hr|km\/ph|kph|kmph|kmh)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 km/h$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})&nbsp;(?:km\/hr|km\/ph|kph|kmph|kmh)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2&nbsp;km/h$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|)\[\[(?:km\/hr|km\/ph|kph|kmph|kmh)\]\]([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 km/h$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})&nbsp;\[\[(?:km\/hr|km\/ph|kph|kmph|kmh)\]\]([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2&nbsp;km/h$3");
 
            //millilitre
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|)(ml)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 $3$4");
 
            // ensure spaces and correct case in kilowatt
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|)kW([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 kW$3");
 
            // ensure spaces and correct case in hertz
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|)Hz([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 Hz$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|)kHz([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 kHz$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|)GHz([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 GHz$3");
            // ensure spaces in megahertz. Must be upper case to avoid clashing with millihertz
            ArticleText = Regex.Replace(ArticleText, @"([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|)MHz([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 MHz$3");
 
            // frames per second
            ArticleText = Regex.Replace(ArticleText, @"(?i)frames\/s(\W)", "frame/s$1");
            ArticleText = Regex.Replace(ArticleText, @"(?i)frames\/sec(\W)", "frame/s$1");
 
            // kilogram
            ArticleText = Regex.Replace(ArticleText, @"(?i)kilogrammes", "kilograms");
            ArticleText = Regex.Replace(ArticleText, @"(?i)kilogramme", "kilogram");
            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(kilograms?)\]\]", "$1");
            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[kilograms?\|(kg|kilograms?)\]\]", "$1");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|)grammes([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 grams$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|)gramme([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 gram$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|)(?:kgs?|\[\[kg\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 kg$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|\d{1,16}\|(?:kg|lb)[^\}]{0,16})\|lk=(?:on|in|out)", "$1");
 
            //foot
            //delink this common unit
            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(foot|feet|ft)\]\]", "$1");
            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(?:foot|feet|ft|foot)\|(foot|feet|ft)\]\]", "$1");
            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[foot \((?:unit|length|unit of length)\)\|(foot|feet|ft)\]\]", "$1");
 
            //convert "foot" to "ft" when in parentheses
            ArticleText = Regex.Replace(ArticleText, @"(?i)(\(\d[\d,\.]{0,16})(?: |-|)(?:feet|foot)(\))", "$1 ft$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)(\(\d[\d,\.]{0,16})&nbsp;(?:feet|foot)(\))", "$1&nbsp;ft$2");
 
            //remove trailing period when in parentheses
            ArticleText = Regex.Replace(ArticleText, @"(?i)(\(\d[\d,\.]{0,16})(?: |-|)ft\.(\))", "$1 ft$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)(\(\d[\d,\.]{0,16})&nbsp;ft\.(\))", "$1&nbsp;ft$2");
 
            // square foot
            //convert "sq foot" to "sq ft"
            ArticleText = Regex.Replace(ArticleText, @"(?i)(\d)( |-)sq\.?( |-|)(feet|foot|ft)", "$1 sq ft");
            ArticleText = Regex.Replace(ArticleText, @"(?i)(\d)&nbsp;sq\.?&nbsp;(feet|foot|ft)", "$1&nbsp;sq&nbsp;ft");
            //convert "square ft" to "sq ft"
            ArticleText = Regex.Replace(ArticleText, @"(?i)(\d)( |-)square( |-)ft", "$1 sq ft");
            ArticleText = Regex.Replace(ArticleText, @"(?i)(\d)&nbsp;square&nbsp;ft", "$1&nbsp;sq&nbsp;ft");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)sq(?: |-|&nbsp;|)ft([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|sqft|sqm|abbr=on}}$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)square(?: |-|&nbsp;|)feet([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|sqft|sqm}}$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)square(?: |-|&nbsp;|)foot([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|sqft|sqm|sing=on}}$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-|&nbsp;|)thousand(?: |-|&nbsp;|)(?:sq|square)\.?(?: |-|&nbsp;|)ft([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2,000|sqft|sqm|abbr=on}}$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-|&nbsp;|)thousand(?: |-|&nbsp;|)(?:sq|square)\.?(?: |-|&nbsp;|)feet([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2,000|sqft|sqm}}$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-|&nbsp;|)thousand(?: |-|&nbsp;|)(?:sq|square)\.?(?: |-|&nbsp;|)foot([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2,000|sqft|sqm|sing=on}}$3");
 
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-|&nbsp;|)million(?: |-|&nbsp;|)(?:sq|square)\.?(?: |-|&nbsp;|)ft([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2,000000|sqft|sqm|abbr=on}}$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})\.(\d)(?: |-|&nbsp;|)million(?: |-|&nbsp;|)(?:sq|square)\.?(?: |-|&nbsp;|)ft([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3,00000|sqft|sqm|abbr=on}}$4");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})\.(\d\d)(?: |-|&nbsp;|)million(?: |-|&nbsp;|)(?:sq|square)\.?(?: |-|&nbsp;|)ft([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3,0000|sqft|sqm|abbr=on}}$4");
 
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-|&nbsp;|)million(?: |-|&nbsp;|)(?:sq|square)\.?(?: |-|&nbsp;|)feet([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2,000000|sqft|sqm}}$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})\.(\d)(?: |-|&nbsp;|)million(?: |-|&nbsp;|)(?:sq|square)\.?(?: |-|&nbsp;|)feet([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3,00000|sqft|sqm}}$4");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})\.(\d\d)(?: |-|&nbsp;|)million(?: |-|&nbsp;|)(?:sq|square)\.?(?: |-|&nbsp;|)feet([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3,0000|sqft|sqm}}$4");
 
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-|&nbsp;|)million(?: |-|&nbsp;|)(?:sq|square)\.?(?: |-|&nbsp;|)foot([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2,000000|sqft|sqm|sing=on}}$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})\.(\d)(?: |-|&nbsp;|)million(?: |-|&nbsp;|)(?:sq|square)\.?(?: |-|&nbsp;|)foot([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3,00000|sqft|sqm|sing=on}}$4");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})\.(\d\d)(?: |-|&nbsp;|)million(?: |-|&nbsp;|)(?:sq|square)\.?(?: |-|&nbsp;|)foot([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3,0000|sqft|sqm|sing=on}}$4");
 
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)ft²([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|sqft|sqm|abbr=on}}$3");
 
            //cubic foot
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-|&nbsp;|)trillion(?: |-|&nbsp;|)(?:cu|cubic)\.?(?: |-|&nbsp;|)feet([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Tcuft|km3}}$4");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-|&nbsp;|)trillion(?: |-|&nbsp;|)(?:cu|cubic)\.?(?: |-|&nbsp;|)foot([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Tcuft|km3|sing=on}}$4");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-|&nbsp;|)trillion(?: |-|&nbsp;|)(?:cu|cubic)\.?(?: |-|&nbsp;|)ft([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Tcuft|km3|abbr=on}}$4");
 
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-|&nbsp;|)billion(?: |-|&nbsp;|)(?:cu|cubic)\.?(?: |-|&nbsp;|)feet([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Gcuft|m3}}$4");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-|&nbsp;|)billion(?: |-|&nbsp;|)(?:cu|cubic)\.?(?: |-|&nbsp;|)foot([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Gcuft|m3|sing=on}}$4");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-|&nbsp;|)billion(?: |-|&nbsp;|)(?:cu|cubic)\.?(?: |-|&nbsp;|)ft([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Gcuft|m3|abbr=on}}$4");
 
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-|&nbsp;|)million(?: |-|&nbsp;|)(?:cu|cubic)\.?(?: |-|&nbsp;|)feet([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Mcuft|m3}}$4");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-|&nbsp;|)million(?: |-|&nbsp;|)(?:cu|cubic)\.?(?: |-|&nbsp;|)foot([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Mcuft|m3|sing=on}}$4");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-|&nbsp;|)million(?: |-|&nbsp;|)(?:cu|cubic)\.?(?: |-|&nbsp;|)ft([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Mcuft|m3|abbr=on}}$4");
 
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-|&nbsp;|)thousand(?: |-|&nbsp;|)(?:cu|cubic)\.?(?: |-|&nbsp;|)feet([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3,000|cuft|m3}}$4");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-|&nbsp;|)thousand(?: |-|&nbsp;|)(?:cu|cubic)\.?(?: |-|&nbsp;|)foot([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3,000|cuft|m3|sing=on}}$4");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-|&nbsp;|)thousand(?: |-|&nbsp;|)(?:cu|cubic)\.?(?: |-|&nbsp;|)ft([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3,000|cuft|m3|abbr=on}}$4");
 
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-|&nbsp;|)(?:cu|cubic)\.?(?: |-|&nbsp;|)feet([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|cuft|m3}}$4");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-|&nbsp;|)(?:cu|cubic)\.?(?: |-|&nbsp;|)foot([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|cuft|m3|sing=on}}$4");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-|&nbsp;|)(?:cu|cubic)\.?(?: |-|&nbsp;|)ft([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|cuft|m3|abbr=on}}$4");
 
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-|&nbsp;|)(?:cu|cubic)\.?(?: |-|&nbsp;|)ft³([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|cuft|m3|abbr=on}}$3");
 
            //cubic foot as bcf, tcf etc
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-|&nbsp;|)bcf([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|Gcuft|m3|abbr=on}}$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-|&nbsp;|)bcf/d([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|Gcuft/d|m3/d|abbr=on}}$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-|&nbsp;|)tcf([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|Tcuft|km3|abbr=on}}$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-|&nbsp;|)tcf/d([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|Tcuft/d|km3/d|abbr=on}}$3");
 
            //convert excessive zeros for cubic foot
            ArticleText = Regex.Replace(ArticleText, @"(?i)({{convert\|\d{1,16})000000000000\|cuft\|", "$1|Tcuft|");
            ArticleText = Regex.Replace(ArticleText, @"(?i)({{convert\|\d{1,16})000000000\|cuft\|", "$1|Gcuft|");
            ArticleText = Regex.Replace(ArticleText, @"(?i)({{convert\|\d{1,16})000000\|cuft\|", "$1|Mcuft|");
 
            //convert excessive zeros for cubic feet
            ArticleText = Regex.Replace(ArticleText, @"(?i)({{convert\|\d{1,16})000000000000\|cuft\|", "$1|Tcuft|");
            ArticleText = Regex.Replace(ArticleText, @"(?i)({{convert\|\d{1,16})000000000\|cuft\|", "$1|Gcuft|");
            ArticleText = Regex.Replace(ArticleText, @"(?i)({{convert\|\d{1,16})000000\|cuft\|", "$1|Mcuft|");
 
            //yard
            //ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(?:yards?)\|(yards?|yds?)\]\]", "$1");
            //ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(yards?|yds?)\]\]", "$1");
            //ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)yards([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|yd}}$3");
            //ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)yard([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|yd|sing=on}}$3");
            //ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)yds?([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|yd|abbr=on}}$3");
 
            //cubic yard
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-|&nbsp;|)trillion(?: |-|&nbsp;|)(?:cu|cubic)\.?(?: |-|&nbsp;|)yards([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2,000000000000|cuyd|m3}}$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-|&nbsp;|)trillion(?: |-|&nbsp;|)(?:cu|cubic)\.?(?: |-|&nbsp;|)yard([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2,000000000000|cuyd|m3|sing=on}}$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-|&nbsp;|)trillion(?: |-|&nbsp;|)(?:cu|cubic)\.?(?: |-|&nbsp;|)yds?([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2,000000000000|cuyd|m3|abbr=on}}$3");
 
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-|&nbsp;|)billion(?: |-|&nbsp;|)(?:cu|cubic)\.?(?: |-|&nbsp;|)yards([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2,000000000|cuyd|m3}}$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-|&nbsp;|)billion(?: |-|&nbsp;|)(?:cu|cubic)\.?(?: |-|&nbsp;|)yard([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2,000000000|cuyd|m3|sing=on}}$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-|&nbsp;|)billion(?: |-|&nbsp;|)(?:cu|cubic)\.?(?: |-|&nbsp;|)yds?([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2,000000000|cuyd|m3|abbr=on}}$3");
 
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-|&nbsp;|)million(?: |-|&nbsp;|)(?:cu|cubic)\.?(?: |-|&nbsp;|)yards([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2,000000|cuyd|m3}}$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-|&nbsp;|)million(?: |-|&nbsp;|)(?:cu|cubic)\.?(?: |-|&nbsp;|)yard([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2,000000|cuyd|m3|sing=on}}$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-|&nbsp;|)million(?: |-|&nbsp;|)(?:cu|cubic)\.?(?: |-|&nbsp;|)yds?([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2,000000|cuyd|m3|abbr=on}}$3");
 
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-|&nbsp;|)thousand(?: |-|&nbsp;|)(?:cu|cubic)\.?(?: |-|&nbsp;|)yards([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2,000|cuyd|m3}}$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-|&nbsp;|)thousand(?: |-|&nbsp;|)(?:cu|cubic)\.?(?: |-|&nbsp;|)yard([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2,000|cuyd|m3|sing=on}}$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-|&nbsp;|)thousand(?: |-|&nbsp;|)(?:cu|cubic)\.?(?: |-|&nbsp;|)yds?([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2,000|cuyd|m3|abbr=on}}$3");
 
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-|&nbsp;|)(?:cu|cubic)\.?(?: |-|&nbsp;|)yards([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|cuyd|m3}}$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-|&nbsp;|)(?:cu|cubic)\.?(?: |-|&nbsp;|)yard([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|cuyd|m3|sing=on}}$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-|&nbsp;|)(?:cu|cubic)\.?(?: |-|&nbsp;|)yds?([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|cuyd|m3|abbr=on}}$3");
 
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-|&nbsp;|)(?:cu|cubic)\.?(?: |-|&nbsp;|)yd³([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|cuyd|m3|abbr=on}}$3");
 
            //oil barrels per day
            //change 'bpd' and 'b/d' into bbl/d
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-|&nbsp;|)(?:bpd|b\/d)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2bbl/d$3");
 
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-|&nbsp;|)trillion(?: |-|&nbsp;|)barrels per day([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Toilbbl/d|km3/d}}$4");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-|&nbsp;|)trillion(?: |-|&nbsp;|)barrel per day([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Toilbbl/d|km3/d|sing=on}}$4");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-|&nbsp;|)trillion(?: |-|&nbsp;|)bbl/d([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Toilbbl/d|km3/d|abbr=on}}$4");
 
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-|&nbsp;|)billion(?: |-|&nbsp;|)barrels per day([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Goilbbl/d|m3/d}}$4");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-|&nbsp;|)billion(?: |-|&nbsp;|)barrel per day([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Goilbbl/d|m3/d|sing=on}}$4");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-|&nbsp;|)billion(?: |-|&nbsp;|)bbl/d([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Goilbbl/d|m3/d|abbr=on}}$4");
 
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-|&nbsp;|)million(?: |-|&nbsp;|)barrels per day([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Moilbbl/d|m3/d}}$4");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-|&nbsp;|)million(?: |-|&nbsp;|)barrel per day([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Moilbbl/d|m3/d|sing=on}}$4");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-|&nbsp;|)million(?: |-|&nbsp;|)bbl/d([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Moilbbl/d|m3/d|abbr=on}}$4");
 
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-|&nbsp;|)thousand(?: |-|&nbsp;|)barrels per day([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3,000|oilbbl/d|m3/d}}$4");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-|&nbsp;|)thousand(?: |-|&nbsp;|)barrel per day([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3,000|oilbbl/d|m3/d|sing=on}}$4");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-|&nbsp;|)thousand(?: |-|&nbsp;|)bbl/d([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3,000|oilbbl/d|m3/d|abbr=on}}$4");
 
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-|&nbsp;|)barrels per day([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|oilbbl/d|m3/d}}$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-|&nbsp;|)barrel per day([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|oilbbl/d|m3/d|sing=on}}$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-|&nbsp;|)bbl/d([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|oilbbl/d|m3/d|abbr=on}}$3");
 
            //oil barrels
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-|&nbsp;|)trillion(?: |-|&nbsp;|)barrels([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Toilbbl|km3}}$4");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-|&nbsp;|)trillion(?: |-|&nbsp;|)barrel([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Toilbbl|km3|sing=on}}$4");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-|&nbsp;|)trillion(?: |-|&nbsp;|)bbl([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Toilbbl|km3|abbr=on}}$4");
 
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-|&nbsp;|)billion(?: |-|&nbsp;|)barrels([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Goilbbl|m3}}$4");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-|&nbsp;|)billion(?: |-|&nbsp;|)barrel([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Goilbbl|m3|sing=on}}$4");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-|&nbsp;|)billion(?: |-|&nbsp;|)bbl([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Goilbbl|m3|abbr=on}}$4");
 
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-|&nbsp;|)million(?: |-|&nbsp;|)barrels([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Moilbbl|m3}}$4");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-|&nbsp;|)million(?: |-|&nbsp;|)barrel([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Moilbbl|m3|sing=on}}$4");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-|&nbsp;|)million(?: |-|&nbsp;|)bbl([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Moilbbl|m3|abbr=on}}$4");
 
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-|&nbsp;|)thousand(?: |-|&nbsp;|)barrels([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3,000|oilbbl|m3}}$4");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-|&nbsp;|)thousand(?: |-|&nbsp;|)barrel([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3,000|oilbbl|m3|sing=on}}$4");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-|&nbsp;|)thousand(?: |-|&nbsp;|)bbl([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3,000|oilbbl|m3|abbr=on}}$4");
 
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-|&nbsp;|)barrels([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|oilbbl|m3}}$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-|&nbsp;|)barrel([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|oilbbl|m3|sing=on}}$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-|&nbsp;|)bbl([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|oilbbl|m3|abbr=on}}$3");
 
            //convert excessive zeros for oil
            ArticleText = Regex.Replace(ArticleText, @"(?i)({{convert\|\d{1,16})000000000000\|oilbbl\|", "$1|Toilbbl|");
            ArticleText = Regex.Replace(ArticleText, @"(?i)({{convert\|\d{1,16})000000000\|oilbbl\|", "$1|Goilbbl|");
            ArticleText = Regex.Replace(ArticleText, @"(?i)({{convert\|\d{1,16})000000\|oilbbl\|", "$1|Moilbbl|");
 
            //oil: cubic km to cubic m
            ArticleText = Regex.Replace(ArticleText, @"(?i)(Moilbbl\|)km3", "$1m3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)(koilbbl\|)km3", "$1m3");
 
            //oil: convert litres into cubic metres
            ArticleText = Regex.Replace(ArticleText, @"(?i)(oilbbl\|)TL", "$1km3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)(oilbbl\|)[kMG]L", "$1m3");
 
            //embed 'per day' into pre-existing conversions
            ArticleText = Regex.Replace(ArticleText, @"(?i)(oilbbl)\|(k?m3)(}})(?: |-|&nbsp;|)(?:per|a)(?: |-|&nbsp;|)day", "$1/d|$2/d$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)(oilbbl)\|(k?m3)(\|abbr=on}})(?: |-|&nbsp;|)(?:per|a)(?: |-|&nbsp;|)day", "$1/d|$2/d$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)(oilbbl)\|(k?m3)(\|sing=on}})(?: |-|&nbsp;|)(?:per|a)(?: |-|&nbsp;|)day", "$1/d|$2/d$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)(oilbbl)\|(k?m3)(}})/d", "$1/d|$2/d");
 
            //feet per second
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|)(?:ft\/second|ft\/sec)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 ft/s$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})&nbsp;(?:ft\/second|ft\/sec)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2&nbsp;ft/s$3");
            //feet per second:plural
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)feet per second([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|ft/s|m/s}}$3");
            //feet per second:singular
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)foot per second([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|ft/s|m/s|sing=on}}$3");
            //feet per second:abbreviated
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)ft\/s([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|ft/s|m/s|abbr=on}}$3");
            //ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)f\/s([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|ft/s|m/s|abbr=on}}$3");
            //ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)fps([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|ft/s|m/s|abbr=on}}$3");
 
            //foot - remove period when followed by parentheses
            ArticleText = Regex.Replace(ArticleText, @"(\d ft)\.( \(\d)", "$1$2");
 
            // foot and inch
            ArticleText = Regex.Replace(ArticleText, @"(?i)(ength[.]{1,3})(\d{1,4}) ?[""’] ?(\d{1,3}) ?[""”]", "$1$2 ft $3 in");
            ArticleText = Regex.Replace(ArticleText, @"(?i)(idth[.]{1,3})(\d{1,4}) ?[""’] ?(\d{1,3}) ?[""”]", "$1$2 ft $3 in");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([\(\|:] ?\d{1,4}) ?[""’] ?(\d{1,3}) ?[""”]([^NESW])", "$1 ft $2 in$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)(\d) ?ft ?(\d{1,3}) ?in", "$1 ft $2 in");
 
            // knot
            ArticleText = Regex.Replace(ArticleText, @"(?i)(\d)( |-|&nbsp;)(?:kts|kt|knt)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2knots$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)\[knot \(unit\)\|", "[knot (speed)|");
            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[kts\]\]", "[[knot (speed)|knots]]");
            ArticleText = Regex.Replace(ArticleText, @"(?i)\|kts\]\]", "|knots]]");
 
            //convert knot template to kn to match km
            ArticleText = Regex.Replace(ArticleText, @"(?i)({{convert\|[\d\.]{1,16})\|knot\|", "$1|kn|");
 
            //nautical mile - rename "miles" as "nautical miles" when followed by knots or conversion code
            ArticleText = Regex.Replace(ArticleText, @"(?i)(\d)(?: |-|&nbsp;|)miles (?:at|@) ([\d\.]{1,9}(?: |-|&nbsp;|)knots|{{convert)", "$1 nautical miles at $2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)(\d)( |-|&nbsp;)(?:mi|nm|nmi) (?:at|@) ([\d\.]{1,9}(?: |-|&nbsp;|)knots|{{convert)", "$1$2nmi at $3");
            //nautical mile: plural unlinked
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)nautical(?: |-|&nbsp;|)miles([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|nmi|km}}$3");
            //nautical mile: plural linked with "s" inside link
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)\[\[nautical(?: |-|&nbsp;|)miles\]\]([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|nmi|km}}$3");
            //nautical mile: plural linked with "s" outside link
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)\[\[nautical(?: |-|&nbsp;|)mile\]\]s([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|nmi|km}}$3");
            //nautical mile: singular unlinked
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)nautical(?: |-|&nbsp;|)mile([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|nmi|km|sing=on}}$3");
            //nautical mile: singular linked
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)\[\[nautical(?: |-|&nbsp;|)mile\]\]([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|nmi|km|sing=on}}$3");
            //nautical mile: abbreviated
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)(?:\[\[nautical mile\|nmi?\]\]|nmi)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|nmi|km|abbr=on}}$3");
            //nautical mile: in full
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] one(?: |-|&nbsp;|)nautical(?: |-|&nbsp;|)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (1.9 km)$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] two(?: |-|&nbsp;|)nautical(?: |-|&nbsp;|)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (4 km)$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] three(?: |-|&nbsp;|)nautical(?: |-|&nbsp;|)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (6 km)$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] four(?: |-|&nbsp;|)nautical(?: |-|&nbsp;|)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (7 km)$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] five(?: |-|&nbsp;|)nautical(?: |-|&nbsp;|)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (9 km)$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] six(?: |-|&nbsp;|)nautical(?: |-|&nbsp;|)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (11 km)$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] seven(?: |-|&nbsp;|)nautical(?: |-|&nbsp;|)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (13 km)$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] eight(?: |-|&nbsp;|)nautical(?: |-|&nbsp;|)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (15 km)$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] nine(?: |-|&nbsp;|)nautical(?: |-|&nbsp;|)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (17 km)$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] ten(?: |-|&nbsp;|)nautical(?: |-|&nbsp;|)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (19 km)$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] eleven(?: |-|&nbsp;|)nautical(?: |-|&nbsp;|)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (20 km)$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] twelve(?: |-|&nbsp;|)nautical(?: |-|&nbsp;|)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (22 km)$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] thirteen(?: |-|&nbsp;|)nautical(?: |-|&nbsp;|)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (24 km)$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] fourteen(?: |-|&nbsp;|)nautical(?: |-|&nbsp;|)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (26 km)$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] fifteen(?: |-|&nbsp;|)nautical(?: |-|&nbsp;|)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (28 km)$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] sixteen(?: |-|&nbsp;|)nautical(?: |-|&nbsp;|)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (30 km)$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] seventeen(?: |-|&nbsp;|)nautical(?: |-|&nbsp;|)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (31 km)$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] eighteen(?: |-|&nbsp;|)nautical(?: |-|&nbsp;|)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (33 km)$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] nineteen(?: |-|&nbsp;|)nautical(?: |-|&nbsp;|)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (35 km)$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] twenty(?: |-|&nbsp;|)nautical(?: |-|&nbsp;|)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (37 km)$2");
 
            //knot - plural
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)(?:knots|\[\[knot \(speed\)\|(?:knots\]\]|knot\]\]s))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|knot|km/h}}$3");
            //knot - singular
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)(?:knot|\[\[knot \(speed\)\|knot\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|knot|km/h|sing=on}}$3");
            //knot - abbreviation
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)(?:kts?|\[\[knot \(speed\)\|kts?\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|knot|km/h|abbr=on}}$3");
 
            //mile - lower case to avoid proper names like "Five Mile Road"
            //delink this common unit
            ArticleText = Regex.Replace(ArticleText, @"\[\[(mi|mile|miles)\]\]", "$1");
            ArticleText = Regex.Replace(ArticleText, @"\[\[(?:mile|miles)\|(mi|mile|miles)\]\]", "$1");
 
            //mile - protect "miles per hour" - undone below
            ArticleText = Regex.Replace(ArticleText, @"(?i)(miles?) (per)", "$1xx$2");
            //miles: plural
            ArticleText = Regex.Replace(ArticleText, @"([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)(?:miles|\[\[miles\]\]|\[\[mile\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|mi|km}}$3");
            //miles: singular
            ArticleText = Regex.Replace(ArticleText, @"([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)(?:mile|\[\[mile\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|mi|km|sing=on}}$3");
            //miles: abbreviated
            ArticleText = Regex.Replace(ArticleText, @"([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)mi([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|mi|km|abbr=on}}$3");
            //miles: in full
            ArticleText = Regex.Replace(ArticleText, @"([^y] one(?: |-|&nbsp;|)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (1.6 km)$2");
            ArticleText = Regex.Replace(ArticleText, @"([^y] two(?: |-|&nbsp;|)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (3 km)$2");
            ArticleText = Regex.Replace(ArticleText, @"([^y] three(?: |-|&nbsp;|)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (5 km)$2");
            ArticleText = Regex.Replace(ArticleText, @"([^y] four(?: |-|&nbsp;|)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (6 km)$2");
            ArticleText = Regex.Replace(ArticleText, @"([^y] five(?: |-|&nbsp;|)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (8 km)$2");
            ArticleText = Regex.Replace(ArticleText, @"([^y] six(?: |-|&nbsp;|)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (10 km)$2");
            ArticleText = Regex.Replace(ArticleText, @"([^y] seven(?: |-|&nbsp;|)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (11 km)$2");
            ArticleText = Regex.Replace(ArticleText, @"([^y] eight(?: |-|&nbsp;|)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (13 km)$2");
            ArticleText = Regex.Replace(ArticleText, @"([^y] nine(?: |-|&nbsp;|)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (14 km)$2");
            ArticleText = Regex.Replace(ArticleText, @"([^y] ten(?: |-|&nbsp;|)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (16 km)$2");
            ArticleText = Regex.Replace(ArticleText, @"([^y] eleven(?: |-|&nbsp;|)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (18 km)$2");
            ArticleText = Regex.Replace(ArticleText, @"([^y] twelve(?: |-|&nbsp;|)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (19 km)$2");
            ArticleText = Regex.Replace(ArticleText, @"([^y] thirteen(?: |-|&nbsp;|)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (19 km)$2");
            ArticleText = Regex.Replace(ArticleText, @"([^y] fourteen(?: |-|&nbsp;|)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (21 km)$2");
            ArticleText = Regex.Replace(ArticleText, @"([^y] fifteen(?: |-|&nbsp;|)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (24 km)$2");
            ArticleText = Regex.Replace(ArticleText, @"([^y] ixteen(?: |-|&nbsp;|)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (26 km)$2");
            ArticleText = Regex.Replace(ArticleText, @"([^y] seventeen(?: |-|&nbsp;|)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (27 km)$2");
            ArticleText = Regex.Replace(ArticleText, @"([^y] eighteen(?: |-|&nbsp;|)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (29 km)$2");
            ArticleText = Regex.Replace(ArticleText, @"([^y] nineteen(?: |-|&nbsp;|)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (30 km)$2");
            ArticleText = Regex.Replace(ArticleText, @"([^y] twenty(?: |-|&nbsp;|)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (32 km)$2");
 
            //mile - unprotect "miles per hour"
            ArticleText = Regex.Replace(ArticleText, @"(?i)(miles?)xx(per)", "$1 $2");
 
            //mile per hour
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)m\.?p\.?h([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|mi/h|km/h|abbr=on}}$3");
 
            // square mile
            ArticleText = Regex.Replace(ArticleText, @"(?i)(\d)(?: |-)sq(?: |\. |-)mi([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 sq mi$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(square mile)\]\]", "$1");
            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[square mile\|(sq mi)\]\]", "$1");
            ArticleText = Regex.Replace(ArticleText, @"(?i)(sq)(?: |-|&nbsp;|)(mile)", "$1uare $2");
            // square mile:plural
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)square(?: |-|&nbsp;|)miles([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|mi2|km2}}$3");
            // square mile:singular
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)square(?: |-|&nbsp;|)mile([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|mi2|km2|sing=on}}$3");
            // square mile:abbreviated
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)sq(?: |-|&nbsp;|)mi([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|mi2|km2|abbr=on}}$3");
 
            //acre foot:plural
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{3,16}[\d,\.]{0,16})(?: |-|&nbsp;|)acre(?: |-|&nbsp;|)feet([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|acre feet}}$3");
            //acre foot:singular
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{3,16}[\d,\.]{0,16})(?: |-|&nbsp;|)acre(?: |-|&nbsp;|)foot([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|acre feet|sing=on}}$3");
            //acre foot:abbreviation
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{3,16}[\d,\.]{0,16})(?: |-|&nbsp;|)(?:acre|ac\.?)(?: |-|&nbsp;|)(?:foot|feet|ft)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|acre ft|abbr=on}}$3");
 
            //acre
            //acres - temporary change to protect acre feet. changed below
            ArticleText = Regex.Replace(ArticleText, @"(?i)(acre)(.(?:feet|foot|ft))", "xx$1yy$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)(\d)-(acre)", "$1 $2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)(\d)(?: |-|&nbsp;|)surface(?: |-|&nbsp;|)acre", "$1 acre");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-|&nbsp;|)thousand(?: |-|&nbsp;|)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2,000|acre|km2}}$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-|&nbsp;|)thousand(?: |-|&nbsp;|)(?:acre|\[\[acre\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2,000|acre|km2|sing=on}}$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-|&nbsp;|)million(?: |-|&nbsp;|)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2,000000|acre|km2}}$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})\.(\d)(?: |-|&nbsp;|)million(?: |-|&nbsp;|)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3,00000|acre|km2}}$4");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})\.(\d)(?: |-|&nbsp;|)million(?: |-|&nbsp;|)(?:acre|\[\[acre\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3,00000|acre|km2|sing=on}}$4");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})\.(\d\d)(?: |-|&nbsp;|)million(?: |-|&nbsp;|)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3,0000|acre|km2}}$4");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})\.(\d\d)(?: |-|&nbsp;|)million(?: |-|&nbsp;|)(?:acre|\[\[acre\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3,0000|acre|km2|sing=on}}$4");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] one(?: |-|&nbsp;|)million(?: |-|&nbsp;|)acres?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (4,000 km²)$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)( a(?: |-|&nbsp;|)million(?: |-|&nbsp;|)acres?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (4,000 km²)$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] two(?: |-|&nbsp;|)million(?: |-|&nbsp;|)acres?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (8,000 km²)$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] three(?: |-|&nbsp;|)million(?: |-|&nbsp;|)acres?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (12,000 km²)$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] four(?: |-|&nbsp;|)million(?: |-|&nbsp;|)acres?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (16,000 km²)$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] five(?: |-|&nbsp;|)million(?: |-|&nbsp;|)acres?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (20,000 km²)$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] six(?: |-|&nbsp;|)million(?: |-|&nbsp;|)acres?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (24,000 km²)$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] seven(?: |-|&nbsp;|)million(?: |-|&nbsp;|)acres?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (28,000 km²)$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] eight(?: |-|&nbsp;|)million(?: |-|&nbsp;|)acres?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (32,000 km²)$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] nine(?: |-|&nbsp;|)million(?: |-|&nbsp;|)acres?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (36,000 km²)$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] ten(?: |-|&nbsp;|)million(?: |-|&nbsp;|)acres?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (40,000 km²)$2");
 
            //acre:plural
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{3,16}[\d,\.]{0,16})(?: |-|&nbsp;|)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|acre|km2}}$3");
            //acre:singular
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{3,16}[\d,\.]{0,16})(?: |-|&nbsp;|)(?:acre|\[\[acre\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|acre|km2|sing=on}}$3");
 
            //acres - undo temporary change to protect acre feet
            ArticleText = Regex.Replace(ArticleText, @"(?i)xx(acre)yy", "$1");
 
            //remove commas from numerical values in convert template
            ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|\d{1,16}),(\d)", "$1$2");
 
            // foot pound
            ArticleText = Regex.Replace(ArticleText, @"(?i)(\W)lbs?[ -.·•\/]{1,2}ft([^²\w])", "$1ft·lbf$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)(\W)lbs?ft([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1ft·lbf$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)ftlbs?([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "ft·lbf$1");
            ArticleText = Regex.Replace(ArticleText, @"(?i)ft\W{1,2}lbs?([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "ft·lbf$1");
            ArticleText = Regex.Replace(ArticleText, @"(?i)ftlbs?([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "ft·lbf$1");
            ArticleText = Regex.Replace(ArticleText, @"(?i)ft\W{1,2}lbf([^\|])", "ft·lbf$1");
            ArticleText = Regex.Replace(ArticleText, @"(?i)ft\W{1,2}lbff", "ft·lbf");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)ft.lbf([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|ft.lbf|N.m|abbr=on}}$3");
 
            //pound force
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})( |-|&nbsp;|)lbs?.? (thrust|of thrust|force|of force)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2$3lbf $4$5");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16}000)(?: |-|&nbsp;|)pounds force([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|lbf|kN}}$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)pounds force([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|lbf|N}}$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16}000)(?: |-|&nbsp;|)pound force([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|lbf|kN|sing=on}}$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)pound force([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|lbf|N|sing=on}}$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16}000)(?: |-|&nbsp;|)lbf([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|lbf|kN|abbr=on}}$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)lbf([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|lbf|abbr=on}}$3");
 
            //pound weight
            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[pound \(weight\)\|([^\]]{1,30})\]\]", "[[pound (mass)|$1]]");
            ArticleText = Regex.Replace(ArticleText, @"(?i)\|lbs?\.\]\]", "|lb]]");
            ArticleText = Regex.Replace(ArticleText, @"(?i)(\d) ?lbs?([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 lb$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)(\d\+?) ?lbs?([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 lb$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)(\d)&nbsp;lbs?([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1&nbsp;lb$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)lb([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|lb|abbr=on}}$3");
            //pounds and ounces - plural
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)pounds(?: |-|&nbsp;|)(\d[\d,\.]{0,16})(?: |-|&nbsp;|)ounces?([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|lb|$3|oz|kg}}$4");
            //pounds and ounces - singular
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)pound(?: |-|&nbsp;|)(\d[\d,\.]{0,16})(?: |-|&nbsp;|)ounces?([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|lb|$3|oz|kg|sing=on}}$4");
            //pounds and ounces - abbreviated
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)lbs?\.?,?(?: |-|&nbsp;|)(\d[\d,\.]{0,16})(?: |-|&nbsp;|)oz\.?([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|lb|$3|oz|kg|abbr=on}}$4");
 
            //grain
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)grains([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|gr}}$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)grain([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|gr|sing=on}}$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)gr([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|gr|abbr=on}}$3");
 
            //foot and inch: plural
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)feet\.?(?: |-|&nbsp;|)(\d[\d,\.]{0,16})(?: |-|&nbsp;|)(?:in|ins|inch|inches)\.?([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|ft|$3|in|m}}$4");
            //foot and inch: singular
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)foot\.?(?: |-|&nbsp;|)(\d[\d,\.]{0,16})(?: |-|&nbsp;|)(?:in|ins|inch|inches)\.?([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|ft|$3|in|m|sing=on}}$4");
            //foot and inch: abbreviated
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)ft\.?(?: |-|&nbsp;|)(\d[\d,\.]{0,16})(?: |-|&nbsp;|)(?:in|ins|inch|inches)\.?([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|ft|$3|in|m|abbr=on}}$4");
 
            //foot (again). Parsed after "foot per second" and "foot pound"
            //foot: plural
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)(?:feet|\[\[Foot \(unit of length\)\|feet\]\])([^²³·\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|ft|m}}$3");
            //foot: singular
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)(?:foot|\[\[Foot \(unit of length\)\|foot\]\])([^²³·\w\d\(\)\/\\][^\d\(\)\/\\p])", "$1{{convert|$2|ft|m|sing=on}}$3");
            //foot: abbreviated
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)(?:ft|\[\[Foot \(unit of length\)\|ft\]\])([^²³·\w\d\(\)\/\\][^\d\(\)\/\\lm])", "$1{{convert|$2|ft|m|abbr=on}}$3");
 
            //inch: plural
            //'inches of snow' converts to cm
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\Wt""’] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)inches(?: |-|&nbsp;|)of(?: |-|&nbsp;|)snow([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|in|cm}}$3");
            //other inches convert to mm
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\Wt""’] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)inches([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|in|mm}}$3");
            // inch: plural with number in words
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] three(?: |-|&nbsp;|)(?:inches|\[\[inches\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (76 mm) $2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] four(?: |-|&nbsp;|)(?:inches|\[\[inches\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (102 mm) $2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] five(?: |-|&nbsp;|)(?:inches|\[\[inches\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (127 mm) $2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] six(?: |-|&nbsp;|)(?:inches|\[\[inches\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (152 mm) $2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] seven(?: |-|&nbsp;|)(?:inches|\[\[inches\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (178 mm) $2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] eight(?: |-|&nbsp;|)(?:inches|\[\[inches\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (203 mm) $2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] nine(?: |-|&nbsp;|)(?:inches|\[\[inches\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (229 mm) $2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] ten(?: |-|&nbsp;|)(?:inches|\[\[inches\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (254 mm) $2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] eleven(?: |-|&nbsp;|)(?:inches|\[\[inches\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (279 mm) $2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] twelve(?: |-|&nbsp;|)(?:inches|\[\[inches\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (305 mm) $2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] thirteen(?: |-|&nbsp;|)(?:inches|\[\[inches\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (330 mm) $2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] fourteen(?: |-|&nbsp;|)(?:inches|\[\[inches\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (356 mm) $2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] fifteen(?: |-|&nbsp;|)(?:inches|\[\[inches\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (381 mm) $2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] sixteen(?: |-|&nbsp;|)(?:inches|\[\[inches\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (406 mm) $2");
            //inch: singular
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\Wt""’] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)(?:inch|\[\[inch\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|in|mm|sing=on}}$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|\d{1,16}\|(?:in|mm|cm)[^\}]{0,16})\|lk=(?:on|in|out)", "$1");
            // inch: singular with number in words
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] three(?: |-|&nbsp;|)(?:inch|\[\[inch\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (76 mm) $2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] four(?: |-|&nbsp;|)(?:inch|\[\[inch\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (102 mm) $2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] five(?: |-|&nbsp;|)(?:inch|\[\[inch\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (127 mm) $2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] six(?: |-|&nbsp;|)(?:inch|\[\[inch\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (152 mm) $2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] seven(?: |-|&nbsp;|)(?:inch|\[\[inch\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (178 mm) $2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] eight(?: |-|&nbsp;|)(?:inch|\[\[inch\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (203 mm) $2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] nine(?: |-|&nbsp;|)(?:inch|\[\[inch\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (229 mm) $2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] ten(?: |-|&nbsp;|)(?:inch|\[\[inch\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (254 mm) $2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] eleven(?: |-|&nbsp;|)(?:inch|\[\[inch\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (279 mm) $2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] twelve(?: |-|&nbsp;|)(?:inch|\[\[inch\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (305 mm) $2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] thirteen(?: |-|&nbsp;|)(?:inch|\[\[inch\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (330 mm) $2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] fourteen(?: |-|&nbsp;|)(?:inch|\[\[inch\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (356 mm) $2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] fifteen(?: |-|&nbsp;|)(?:inch|\[\[inch\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (381 mm) $2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] sixteen(?: |-|&nbsp;|)(?:inch|\[\[inch\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (406 mm) $2");
 
            // horsepower
            ArticleText = Regex.Replace(ArticleText, @"(?i)\.28 ?(bhp|ihp|shp)\.29\|", "($1)|");
            ArticleText = Regex.Replace(ArticleText, @"(?i)(\d)(?: |-|)(horsepower|hp|bhp|ihp|shp)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 $2$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)(\d)&nbsp;(horsepower|hp|bhp|ihp|shp)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1&nbsp;$2$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)(\d)(?: |-|)horse(?: |-|)power([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 horsepower$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)(?:horsepower|\[\[horsepower\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|hp}}$3");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)(indicated(?: |-|&nbsp;|)horsepower)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|ihp}}$4");
            ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|&nbsp;|)(hp|bhp|ihp|shp)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|$3|abbr=on}}$4");
 
            // rpm
            ArticleText = Regex.Replace(ArticleText, @"(?i)(\d) ?rpm([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 rpm$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)(\d)&nbsp;rpm([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1&nbsp;rpm$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)(\d)\-rpm([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 rpm$2");
 
            // bits per second
            ArticleText = Regex.Replace(ArticleText, @"([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|)([KkMmGgTt]|)(?:bps|bits\/s|b\/s|bits?\/sec)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 $3bit/s$4");
            ArticleText = Regex.Replace(ArticleText, @"([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?:&nbsp;)([KkMmGgTt]|)(?:bps|bits\/s|b\/s|bits?\/sec)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 $3bit/s$4");
 
            // bytes per second
            ArticleText = Regex.Replace(ArticleText, @"([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|)([KkMmGgTt]|)(?:Bps|bytes?\/s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 $3byte/s$4");
            ArticleText = Regex.Replace(ArticleText, @"([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?:&nbsp;)([KkMmGgTt]|)(?:Bps|bytes?\/s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 $3byte/s$4");
 
            // capitalization of prefix with bits and bytes
            ArticleText = Regex.Replace(ArticleText, @"K(bit|B|byte)\/s", "k$1/s");
            ArticleText = Regex.Replace(ArticleText, @"m(bit|B|byte)\/s", "M$1/s");
            ArticleText = Regex.Replace(ArticleText, @"g(bit|B|byte)\/s", "G$1/s");
            ArticleText = Regex.Replace(ArticleText, @"t(bit|B|byte)\/s", "T$1/s");
 
            //aviation specifications: unprotect "main=" and "alt="
            ArticleText = Regex.Replace(ArticleText, @"(?i)((?:main|alt) ?= ?)xx(\d)", "$1$2");
 
            //replace other templates with convert template
            ArticleText = Regex.Replace(ArticleText, @"(?i){{mi to km\|(\d{1,9})}}", "{{convert|$1|mi|km}}");
            ArticleText = Regex.Replace(ArticleText, @"(?i){{mi to km\|(\d{1,9})\|round[^\}]{1,5}}}", "{{convert|$1|mi|km}}");
            ArticleText = Regex.Replace(ArticleText, @"(?i){{mi2 to km2\|(\d{1,9})}}", "{{convert|$1|mi|km}}");
            ArticleText = Regex.Replace(ArticleText, @"(?i){{mi2 to km2\|(\d{1,9})\|round[^\}]{1,5}}}", "{{convert|$1|mi|km}}");
 
            //remove commas from numerical values in convert template
            ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|\d{1,16}),(\d)", "$1$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|\d{1,16}),(\d)", "$1$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|\d{1,16}),(\d)", "$1$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|\d{1,16}),(\d)", "$1$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|\d{1,16}),(\d)", "$1$2");
 
            //remove leading zeros from convert template
            ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|)0(\d)", "$1$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|)0(\d)", "$1$2");
            ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|)0(\d)", "$1$2");
 
            //Remove surprise or "Easter egg" diversions linking unit name to orders of magnitude articles
            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[1 ?_?E ?[\-\+]?\d{1,2} ?..?\|([^\]]{1,50})\]\]", "$1");
            ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[Orders of magnitude \([^\)]{1,30}\)\|([^\]]{1,50})\]\]", "$1");
 
            return ArticleText;
        }