User:Lightmouse/javascript conversion
Appearance
//
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);
//year: temporary change to protect band '4AD'. Undone below
ArticleText = Regex.Replace(ArticleText, @"\[\[4AD\]\]", "[[xx4ADxx]]");
// 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_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
//protect some
ArticleText = Regex.Replace(ArticleText, @"(?i)(\[\[\d{1,4} in) ((?:baseball|film|literature|comics)\|\d{1,4}\]\])", "$1xx$2");
//now removed the piped years
ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[\d{1,4} in [^\|]+\|(\d{1,4})\]\]", "[[$1]]");
//unprotect baseball and film
ArticleText = Regex.Replace(ArticleText, @"(?i)(\[\[\d{1,4} in)xx((?:baseball|film|literature|comics)\|\d{1,4}\]\])", "$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");
//'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]]");
//year: unprotect band '4AD'.
ArticleText = Regex.Replace(ArticleText, @"\[\[xx4ADxx\]\]", "[[4AD]]");
//remove flagicons from birth and death
ArticleText = Regex.Replace(ArticleText, @"(?i)(birth ?= ?)\{\{flagicon\|[^\}]+\}\}", "$1");
ArticleText = Regex.Replace(ArticleText, @"(?i)(death ?= ?)\{\{flagicon\|[^\}]+\}\}", "$1");
ArticleText = Regex.Replace(ArticleText, @"(?i)(birth_?place ?= ?)\{\{flagicon\|[^\}]+\}\}", "$1");
ArticleText = Regex.Replace(ArticleText, @"(?i)(death_?place ?= ?)\{\{flagicon\|[^\}]+\}\}", "$1");
//symbol for superscript 2 and 3
//ArticleText = Regex.Replace(ArticleText, @"(?i)<sup>2<\/sup>", "²");
//ArticleText = Regex.Replace(ArticleText, @"(?i)<sup>3<\/sup>", "³");
//delink common units
ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|[\d\.]*\|(?:mm|mm2|mm3|cm|cm2|cm3|m|m2|m3|km|km2|km3|g|kg|mL|L|in|in2|in3|ft|sqft|ft2|cuft|ft3|yd|sqyd|yd2|cuyd|yd3|mi|sqmi|mi2|cumi|mi3|acre|nmi|lb|USgal)\|[^\}]*)\|lk=(?:on|in|out)", "$1");
ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|[^\}]*)\|lk=off", "$1");
// Convert degree symbols into ° symbol, ensure preceding space
ArticleText = Regex.Replace(ArticleText, @"(?i)°", "°");
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)(?: | |)(C|F)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "°$1$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)(?:°|deg\.?)(?: | |)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,\.]*)(?: |-| |)°F([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|°F|°C|abbr=on}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(-?\d[\d,\.]*)(?: |-| |)(?:deg|degree|degrees)(?: |-| |)Fahrenheit([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|°F|°C}}$3");
// Convert &sup to superscript
ArticleText = Regex.Replace(ArticleText, @"(?i)²", "²");
ArticleText = Regex.Replace(ArticleText, @"(?i)³", "³");
//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,\.]*)(?: |-|)m([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 m$3");
//convert "metres" to "m" when in parentheses
ArticleText = Regex.Replace(ArticleText, @"(?i)(\(\d[\d,\.]*)(?: |-|)(?:metres|meters|metre|meter)(\))", "$1 m$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)(\(\d[\d,\.]*) (?:metres|meters|metre|meter)(\))", "$1 m$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|\d+\|(?:m|ft)\|[^\}]*)\|lk=(?:on|in|out)", "$1");
//metre per second
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*)(?: |-|)(?:m\/second|m\/sec)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 m/s$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*) (?:m\/second|m\/sec)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 m/s$3");
//square metre
ArticleText = Regex.Replace(ArticleText, @"(?i)(\d)(?: |-| |)sq(?: |\. |-| )m([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 m²$2");
//remove period when followed by close parenthesis character
ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|\d+\|(?:sqm|sqft)[^\}]*)\|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,\.]*)(?: |-|)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,\.]*)(?: |-|)(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+\|(?:mi|km)[^\}]*)\|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\.?(?: |-| |)kms?", "$1km²");
ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|\d+\|(?:sqkm|sqmi|km2|mi2)[^\}]*)\|lk=(?:on|in|out)", "$1");
//kilometre per second
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*)(?: |-|)(?:km\/second|km\/sec)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 km/s$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*) (?:km\/second|km\/sec)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 km/s$3");
// kilometre per hour
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*)(?: |-|)(?:km\/hr|km\/ph|kph|kmph|kmh)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 km/h$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*) (?:km\/hr|km\/ph|kph|kmph|kmh)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 km/h$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*)(?: |-|)\[\[(?:km\/hr|km\/ph|kph|kmph|kmh)\]\]([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 km/h$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*) \[\[(?:km\/hr|km\/ph|kph|kmph|kmh)\]\]([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 km/h$3");
//millilitre
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*)(?: |-|)(ml)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 $3$4");
// ensure spaces and correct case in kilowatt
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*)(?: |-|)kW([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 kW$3");
// ensure spaces and correct case in hertz
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*)(?: |-|)Hz([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 Hz$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*)(?: |-|)kHz([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 kHz$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*)(?: |-|)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,\.]*)(?: |-|)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,\.]*)(?: |-|)grammes([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 grams$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*)(?: |-|)gramme([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 gram$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*)(?: |-|)(?:kgs?|\[\[kg\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 kg$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|\d+\|(?:kg|lb)[^\}]*)\|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,\.]*)(?: |-|)(?:feet|foot)(\))", "$1 ft$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)(\(\d[\d,\.]*) (?:feet|foot)(\))", "$1 ft$2");
//remove trailing period when in parentheses
ArticleText = Regex.Replace(ArticleText, @"(?i)(\(\d[\d,\.]*)(?: |-|)ft\.(\))", "$1 ft$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)(\(\d[\d,\.]*) ft\.(\))", "$1 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) sq\.? (feet|foot|ft)", "$1 sq ft");
//convert "square ft" to "sq ft"
ArticleText = Regex.Replace(ArticleText, @"(?i)(\d)( |-)square( |-)ft", "$1 sq ft");
ArticleText = Regex.Replace(ArticleText, @"(?i)(\d) square ft", "$1 sq ft");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*)(?: |-| |)sq(?: |-| |)ft([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|sqft|m2|abbr=on}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*)(?: |-| |)square(?: |-| |)feet([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|sqft|m2}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*)(?: |-| |)square(?: |-| |)foot([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|sqft|m2|sing=on}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(?: |-| |)thousand(?: |-| |)(?:sq|square)\.?(?: |-| |)ft([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2,000|sqft|m2|abbr=on}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(?: |-| |)thousand(?: |-| |)(?:sq|square)\.?(?: |-| |)feet([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2,000|sqft|m2}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(?: |-| |)thousand(?: |-| |)(?:sq|square)\.?(?: |-| |)foot([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2,000|sqft|m2|sing=on}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(?: |-| |)million(?: |-| |)(?:sq|square)\.?(?: |-| |)ft([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2,000000|sqft|m2|abbr=on}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)\.(\d)(?: |-| |)million(?: |-| |)(?:sq|square)\.?(?: |-| |)ft([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3,00000|sqft|m2|abbr=on}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)\.(\d\d)(?: |-| |)million(?: |-| |)(?:sq|square)\.?(?: |-| |)ft([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3,0000|sqft|m2|abbr=on}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(?: |-| |)million(?: |-| |)(?:sq|square)\.?(?: |-| |)feet([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2,000000|sqft|m2}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)\.(\d)(?: |-| |)million(?: |-| |)(?:sq|square)\.?(?: |-| |)feet([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3,00000|sqft|m2}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)\.(\d\d)(?: |-| |)million(?: |-| |)(?:sq|square)\.?(?: |-| |)feet([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3,0000|sqft|m2}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(?: |-| |)million(?: |-| |)(?:sq|square)\.?(?: |-| |)foot([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2,000000|sqft|m2|sing=on}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)\.(\d)(?: |-| |)million(?: |-| |)(?:sq|square)\.?(?: |-| |)foot([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3,00000|sqft|m2|sing=on}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)\.(\d\d)(?: |-| |)million(?: |-| |)(?:sq|square)\.?(?: |-| |)foot([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3,0000|sqft|m2|sing=on}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*)(?: |-| |)ft²([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|sqft|m2|abbr=on}}$3");
//cubic foot
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(\.[\d,]{1,3})?(?: |-| |)trillion(?: |-| |)(?:cu|cubic)\.?(?: |-| |)feet([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Tcuft|km3}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(\.[\d,]{1,3})?(?: |-| |)trillion(?: |-| |)(?:cu|cubic)\.?(?: |-| |)foot([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Tcuft|km3|sing=on}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(\.[\d,]{1,3})?(?: |-| |)trillion(?: |-| |)(?:cu|cubic)\.?(?: |-| |)ft([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Tcuft|km3|abbr=on}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(\.[\d,]{1,3})?(?: |-| |)billion(?: |-| |)(?:cu|cubic)\.?(?: |-| |)feet([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Gcuft|m3}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(\.[\d,]{1,3})?(?: |-| |)billion(?: |-| |)(?:cu|cubic)\.?(?: |-| |)foot([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Gcuft|m3|sing=on}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(\.[\d,]{1,3})?(?: |-| |)billion(?: |-| |)(?:cu|cubic)\.?(?: |-| |)ft([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Gcuft|m3|abbr=on}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(\.[\d,]{1,3})?(?: |-| |)million(?: |-| |)(?:cu|cubic)\.?(?: |-| |)feet([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Mcuft|m3}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(\.[\d,]{1,3})?(?: |-| |)million(?: |-| |)(?:cu|cubic)\.?(?: |-| |)foot([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Mcuft|m3|sing=on}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(\.[\d,]{1,3})?(?: |-| |)million(?: |-| |)(?:cu|cubic)\.?(?: |-| |)ft([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Mcuft|m3|abbr=on}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(\.[\d,]{1,3})?(?: |-| |)thousand(?: |-| |)(?:cu|cubic)\.?(?: |-| |)feet([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3,000|cuft|m3}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(\.[\d,]{1,3})?(?: |-| |)thousand(?: |-| |)(?:cu|cubic)\.?(?: |-| |)foot([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3,000|cuft|m3|sing=on}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(\.[\d,]{1,3})?(?: |-| |)thousand(?: |-| |)(?:cu|cubic)\.?(?: |-| |)ft([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3,000|cuft|m3|abbr=on}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(\.[\d,]{1,3})?(?: |-| |)(?:cu|cubic)\.?(?: |-| |)feet([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|cuft|m3}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(\.[\d,]{1,3})?(?: |-| |)(?:cu|cubic)\.?(?: |-| |)foot([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|cuft|m3|sing=on}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(\.[\d,]{1,3})?(?: |-| |)(?:cu|cubic)\.?(?: |-| |)ft([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|cuft|m3|abbr=on}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(?: |-| |)(?:cu|cubic)\.?(?: |-| |)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,]+)(?: |-| |)bcf([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|Gcuft|m3|abbr=on}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(?: |-| |)bcf/d([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|Gcuft/d|m3/d|abbr=on}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(?: |-| |)tcf([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|Tcuft|km3|abbr=on}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(?: |-| |)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+)000000000000\|ft3\|", "$1|Tcuft|");
ArticleText = Regex.Replace(ArticleText, @"(?i)({{convert\|\d+)000000000\|ft3\|", "$1|Gcuft|");
ArticleText = Regex.Replace(ArticleText, @"(?i)({{convert\|\d+)000000\|ft3\|", "$1|Mcuft|");
//convert excessive zeros for cubic feet
ArticleText = Regex.Replace(ArticleText, @"(?i)({{convert\|\d+)000000000000\|ft3\|", "$1|Tcuft|");
ArticleText = Regex.Replace(ArticleText, @"(?i)({{convert\|\d+)000000000\|ft3\|", "$1|Gcuft|");
ArticleText = Regex.Replace(ArticleText, @"(?i)({{convert\|\d+)000000\|ft3\|", "$1|Mcuft|");
//convert deprecated template for cubic foot
ArticleText = Regex.Replace(ArticleText, @"(?i)({{convert\|\d+)\|ft3\|", "$1|cuft|");
ArticleText = Regex.Replace(ArticleText, @"(?i)({{convert\|\d+)\|(gmtk)ft3\|", "$1|$2cuft|");
//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,\.]*)(?: |-| |)yards([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|yd}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*)(?: |-| |)yard([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|yd|sing=on}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*)(?: |-| |)yds?([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|yd|abbr=on}}$3");
//cubic yard
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(?: |-| |)trillion(?: |-| |)(?:cu|cubic)\.?(?: |-| |)yards([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2,000000000000|cuyd|m3}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(?: |-| |)trillion(?: |-| |)(?:cu|cubic)\.?(?: |-| |)yard([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2,000000000000|cuyd|m3|sing=on}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(?: |-| |)trillion(?: |-| |)(?:cu|cubic)\.?(?: |-| |)yds?([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2,000000000000|cuyd|m3|abbr=on}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(?: |-| |)billion(?: |-| |)(?:cu|cubic)\.?(?: |-| |)yards([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2,000000000|cuyd|m3}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(?: |-| |)billion(?: |-| |)(?:cu|cubic)\.?(?: |-| |)yard([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2,000000000|cuyd|m3|sing=on}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(?: |-| |)billion(?: |-| |)(?:cu|cubic)\.?(?: |-| |)yds?([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2,000000000|cuyd|m3|abbr=on}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(?: |-| |)million(?: |-| |)(?:cu|cubic)\.?(?: |-| |)yards([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2,000000|cuyd|m3}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(?: |-| |)million(?: |-| |)(?:cu|cubic)\.?(?: |-| |)yard([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2,000000|cuyd|m3|sing=on}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(?: |-| |)million(?: |-| |)(?:cu|cubic)\.?(?: |-| |)yds?([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2,000000|cuyd|m3|abbr=on}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(?: |-| |)thousand(?: |-| |)(?:cu|cubic)\.?(?: |-| |)yards([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2,000|cuyd|m3}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(?: |-| |)thousand(?: |-| |)(?:cu|cubic)\.?(?: |-| |)yard([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2,000|cuyd|m3|sing=on}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(?: |-| |)thousand(?: |-| |)(?:cu|cubic)\.?(?: |-| |)yds?([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2,000|cuyd|m3|abbr=on}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(?: |-| |)(?:cu|cubic)\.?(?: |-| |)yards([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|cuyd|m3}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(?: |-| |)(?:cu|cubic)\.?(?: |-| |)yard([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|cuyd|m3|sing=on}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(?: |-| |)(?:cu|cubic)\.?(?: |-| |)yds?([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|cuyd|m3|abbr=on}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(?: |-| |)(?:cu|cubic)\.?(?: |-| |)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,]+)(?: |-| |)(?:bpd|b\/d)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2bbl/d$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(\.[\d,]{1,3})?(?: |-| |)trillion(?: |-| |)barrels per day([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Toilbbl/d|km3/d}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(\.[\d,]{1,3})?(?: |-| |)trillion(?: |-| |)barrel per day([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Toilbbl/d|km3/d|sing=on}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(\.[\d,]{1,3})?(?: |-| |)trillion(?: |-| |)bbl/d([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Toilbbl/d|km3/d|abbr=on}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(\.[\d,]{1,3})?(?: |-| |)billion(?: |-| |)barrels per day([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Goilbbl/d|m3/d}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(\.[\d,]{1,3})?(?: |-| |)billion(?: |-| |)barrel per day([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Goilbbl/d|m3/d|sing=on}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(\.[\d,]{1,3})?(?: |-| |)billion(?: |-| |)bbl/d([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Goilbbl/d|m3/d|abbr=on}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(\.[\d,]{1,3})?(?: |-| |)million(?: |-| |)barrels per day([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Moilbbl/d|m3/d}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(\.[\d,]{1,3})?(?: |-| |)million(?: |-| |)barrel per day([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Moilbbl/d|m3/d|sing=on}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(\.[\d,]{1,3})?(?: |-| |)million(?: |-| |)bbl/d([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Moilbbl/d|m3/d|abbr=on}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(\.[\d,]{1,3})?(?: |-| |)thousand(?: |-| |)barrels per day([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3,000|oilbbl/d|m3/d}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(\.[\d,]{1,3})?(?: |-| |)thousand(?: |-| |)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,]+)(\.[\d,]{1,3})?(?: |-| |)thousand(?: |-| |)bbl/d([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3,000|oilbbl/d|m3/d|abbr=on}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(?: |-| |)barrels per day([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|oilbbl/d|m3/d}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(?: |-| |)barrel per day([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|oilbbl/d|m3/d|sing=on}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(?: |-| |)bbl/d([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|oilbbl/d|m3/d|abbr=on}}$3");
//oil barrels
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(\.[\d,]{1,3})?(?: |-| |)trillion(?: |-| |)barrels([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Toilbbl|km3}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(\.[\d,]{1,3})?(?: |-| |)trillion(?: |-| |)barrel([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Toilbbl|km3|sing=on}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(\.[\d,]{1,3})?(?: |-| |)trillion(?: |-| |)bbl([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Toilbbl|km3|abbr=on}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(\.[\d,]{1,3})?(?: |-| |)billion(?: |-| |)barrels([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Goilbbl|m3}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(\.[\d,]{1,3})?(?: |-| |)billion(?: |-| |)barrel([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Goilbbl|m3|sing=on}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(\.[\d,]{1,3})?(?: |-| |)billion(?: |-| |)bbl([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Goilbbl|m3|abbr=on}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(\.[\d,]{1,3})?(?: |-| |)million(?: |-| |)barrels([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Moilbbl|m3}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(\.[\d,]{1,3})?(?: |-| |)million(?: |-| |)barrel([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Moilbbl|m3|sing=on}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(\.[\d,]{1,3})?(?: |-| |)million(?: |-| |)bbl([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3|Moilbbl|m3|abbr=on}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(\.[\d,]{1,3})?(?: |-| |)thousand(?: |-| |)barrels([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3,000|oilbbl|m3}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(\.[\d,]{1,3})?(?: |-| |)thousand(?: |-| |)barrel([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3,000|oilbbl|m3|sing=on}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(\.[\d,]{1,3})?(?: |-| |)thousand(?: |-| |)bbl([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3,000|oilbbl|m3|abbr=on}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(?: |-| |)barrels([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|oilbbl|m3}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(?: |-| |)barrel([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|oilbbl|m3|sing=on}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(?: |-| |)bbl([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|oilbbl|m3|abbr=on}}$3");
//convert excessive zeros for oil
ArticleText = Regex.Replace(ArticleText, @"(?i)({{convert\|\d+)000000000000\|oilbbl\|", "$1|Toilbbl|");
ArticleText = Regex.Replace(ArticleText, @"(?i)({{convert\|\d+)000000000\|oilbbl\|", "$1|Goilbbl|");
ArticleText = Regex.Replace(ArticleText, @"(?i)({{convert\|\d+)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)(}})(?: |-| |)(?:per|a)(?: |-| |)day", "$1/d|$2/d$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)(oilbbl)\|(k?m3)(\|abbr=on}})(?: |-| |)(?:per|a)(?: |-| |)day", "$1/d|$2/d$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)(oilbbl)\|(k?m3)(\|sing=on}})(?: |-| |)(?:per|a)(?: |-| |)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,\.]*)(?: |-|)(?:ft\/second|ft\/sec)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 ft/s$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*) (?:ft\/second|ft\/sec)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 ft/s$3");
//feet per second:plural
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*)(?: |-| |)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,\.]*)(?: |-| |)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,\.]*)(?: |-| |)ft\/s([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|ft/s|m/s|abbr=on}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*)(?: |-| |)f\/s([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|ft/s|m/s|abbr=on}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*)(?: |-| |)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)( |-| )(?: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\.]+)\|knot\|", "$1|kn|");
//nautical mile - rename "miles" as "nautical miles" when followed by knots or conversion code
ArticleText = Regex.Replace(ArticleText, @"(?i)(\d)(?: |-| |)miles (?:at|@) ([\d\.]{1,9}(?: |-| |)knots|{{convert)", "$1 nautical miles at $2");
ArticleText = Regex.Replace(ArticleText, @"(?i)(\d)( |-| )(?:mi|nm|nmi) (?:at|@) ([\d\.]{1,9}(?: |-| |)knots|{{convert)", "$1$2nmi at $3");
//nautical mile: plural unlinked
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*)(?: |-| |)nautical(?: |-| |)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,\.]*)(?: |-| |)\[\[nautical(?: |-| |)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,\.]*)(?: |-| |)\[\[nautical(?: |-| |)mile\]\]s([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|nmi|km}}$3");
//nautical mile: singular unlinked
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*)(?: |-| |)nautical(?: |-| |)mile([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|nmi|km|sing=on}}$3");
//nautical mile: singular linked
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*)(?: |-| |)\[\[nautical(?: |-| |)mile\]\]([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|nmi|km|sing=on}}$3");
//nautical mile: abbreviated
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*)(?: |-| |)(?:\[\[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(?: |-| |)nautical(?: |-| |)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (1.9 km)$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] two(?: |-| |)nautical(?: |-| |)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (4 km)$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] three(?: |-| |)nautical(?: |-| |)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (6 km)$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] four(?: |-| |)nautical(?: |-| |)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (7 km)$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] five(?: |-| |)nautical(?: |-| |)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (9 km)$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] six(?: |-| |)nautical(?: |-| |)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (11 km)$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] seven(?: |-| |)nautical(?: |-| |)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (13 km)$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] eight(?: |-| |)nautical(?: |-| |)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (15 km)$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] nine(?: |-| |)nautical(?: |-| |)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (17 km)$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] ten(?: |-| |)nautical(?: |-| |)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (19 km)$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] eleven(?: |-| |)nautical(?: |-| |)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (20 km)$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] twelve(?: |-| |)nautical(?: |-| |)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (22 km)$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] thirteen(?: |-| |)nautical(?: |-| |)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (24 km)$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] fourteen(?: |-| |)nautical(?: |-| |)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (26 km)$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] fifteen(?: |-| |)nautical(?: |-| |)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (28 km)$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] sixteen(?: |-| |)nautical(?: |-| |)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (30 km)$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] seventeen(?: |-| |)nautical(?: |-| |)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (31 km)$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] eighteen(?: |-| |)nautical(?: |-| |)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (33 km)$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] nineteen(?: |-| |)nautical(?: |-| |)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (35 km)$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] twenty(?: |-| |)nautical(?: |-| |)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (37 km)$2");
//knot - plural
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*)(?: |-| |)(?:knots|\[\[knot \(speed\)\|(?:knots\]\]|knot\]\]s))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|kn|km/h}}$3");
//knot - singular
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*)(?: |-| |)(?:knot|\[\[knot \(speed\)\|knot\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|kn|km/h|sing=on}}$3");
//knot - abbreviation
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*)(?: |-| |)(?:kts?|\[\[knot \(speed\)\|kts?\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|kn|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,\.]*)(?: |-| |)(?:miles|\[\[miles\]\]|\[\[mile\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|mi|km}}$3");
//miles: singular
ArticleText = Regex.Replace(ArticleText, @"([^\d\(\)\/\\] )(\d[\d,\.]*)(?: |-| |)(?:mile|\[\[mile\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|mi|km|sing=on}}$3");
//miles: abbreviated
ArticleText = Regex.Replace(ArticleText, @"([^\d\(\)\/\\] )(\d[\d,\.]*)(?: |-| |)mi([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|mi|km|abbr=on}}$3");
//miles: in full
ArticleText = Regex.Replace(ArticleText, @"([^y] one(?: |-| |)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (1.6 km)$2");
ArticleText = Regex.Replace(ArticleText, @"([^y] two(?: |-| |)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (3 km)$2");
ArticleText = Regex.Replace(ArticleText, @"([^y] three(?: |-| |)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (5 km)$2");
ArticleText = Regex.Replace(ArticleText, @"([^y] four(?: |-| |)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (6 km)$2");
ArticleText = Regex.Replace(ArticleText, @"([^y] five(?: |-| |)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (8 km)$2");
ArticleText = Regex.Replace(ArticleText, @"([^y] six(?: |-| |)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (10 km)$2");
ArticleText = Regex.Replace(ArticleText, @"([^y] seven(?: |-| |)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (11 km)$2");
ArticleText = Regex.Replace(ArticleText, @"([^y] eight(?: |-| |)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (13 km)$2");
ArticleText = Regex.Replace(ArticleText, @"([^y] nine(?: |-| |)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (14 km)$2");
ArticleText = Regex.Replace(ArticleText, @"([^y] ten(?: |-| |)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (16 km)$2");
ArticleText = Regex.Replace(ArticleText, @"([^y] eleven(?: |-| |)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (18 km)$2");
ArticleText = Regex.Replace(ArticleText, @"([^y] twelve(?: |-| |)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (19 km)$2");
ArticleText = Regex.Replace(ArticleText, @"([^y] thirteen(?: |-| |)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (19 km)$2");
ArticleText = Regex.Replace(ArticleText, @"([^y] fourteen(?: |-| |)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (21 km)$2");
ArticleText = Regex.Replace(ArticleText, @"([^y] fifteen(?: |-| |)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (24 km)$2");
ArticleText = Regex.Replace(ArticleText, @"([^y] ixteen(?: |-| |)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (26 km)$2");
ArticleText = Regex.Replace(ArticleText, @"([^y] seventeen(?: |-| |)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (27 km)$2");
ArticleText = Regex.Replace(ArticleText, @"([^y] eighteen(?: |-| |)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (29 km)$2");
ArticleText = Regex.Replace(ArticleText, @"([^y] nineteen(?: |-| |)miles?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (30 km)$2");
ArticleText = Regex.Replace(ArticleText, @"([^y] twenty(?: |-| |)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,\.]*)(?: |-| |)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)(?: |-| |)(mile)", "$1uare $2");
// square mile:plural
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*)(?: |-| |)square(?: |-| |)miles([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|sqmi|km2}}$3");
// square mile:singular
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*)(?: |-| |)square(?: |-| |)mile([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|sqmi|km2|sing=on}}$3");
// square mile:abbreviated
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*)(?: |-| |)sq(?: |-| |)mi([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|sqmi|km2|abbr=on}}$3");
//acre foot:plural
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{3,16}[\d,\.]*)(?: |-| |)acre(?: |-| |)feet([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|acre feet}}$3");
//acre foot:singular
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{3,16}[\d,\.]*)(?: |-| |)acre(?: |-| |)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,\.]*)(?: |-| |)(?:acre|ac\.?)(?: |-| |)(?:foot|feet|ft)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|acre ft|abbr=on}}$3");
//acre - compress piped link
ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[acre\|(acre)s\]\]", "[[$1]]s");
ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(acre)s\]\]", "[[$1]]s");
//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)(?: |-| |)surface(?: |-| |)acre", "$1 acre");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(?: |-| |)thousand(?: |-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2,000|acre|km2}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(?: |-| |)thousand(?: |-| |)(?:acre|\[\[acre\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2,000|acre|km2|sing=on}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)(?: |-| |)million(?: |-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|e6acre|km2}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)\.(\d)(?: |-| |)million(?: |-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3,00000|acre|km2}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)\.(\d)(?: |-| |)million(?: |-| |)(?:acre|\[\[acre\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3,00000|acre|km2|sing=on}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)\.(\d\d)(?: |-| |)million(?: |-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3,0000|acre|km2}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]+)\.(\d\d)(?: |-| |)million(?: |-| |)(?:acre|\[\[acre\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2$3,0000|acre|km2|sing=on}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] one(?: |-| |)million(?: |-| |)acres?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (4,000 km²)$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)( a(?: |-| |)million(?: |-| |)acres?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (4,000 km²)$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] two(?: |-| |)million(?: |-| |)acres?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (8,000 km²)$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] three(?: |-| |)million(?: |-| |)acres?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (12,000 km²)$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] four(?: |-| |)million(?: |-| |)acres?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (16,000 km²)$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] five(?: |-| |)million(?: |-| |)acres?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (20,000 km²)$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] six(?: |-| |)million(?: |-| |)acres?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (24,000 km²)$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] seven(?: |-| |)million(?: |-| |)acres?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (28,000 km²)$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] eight(?: |-| |)million(?: |-| |)acres?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (32,000 km²)$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] nine(?: |-| |)million(?: |-| |)acres?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (36,000 km²)$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^y] ten(?: |-| |)million(?: |-| |)acres?)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (40,000 km²)$2");
//acre:plural in full
ArticleText = Regex.Replace(ArticleText, @"(?i)([^y][^-])two(?: |-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|2|acre|m2}}$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^y][^-])three(?: |-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|3|acre|m2}}$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^y][^-])four(?: |-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|4|acre|m2}}$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^y][^-])five(?: |-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|5|acre|m2}}$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^y][^-])six(?: |-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|6|acre|m2}}$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^y][^-])seven(?: |-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|7|acre|m2}}$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^y][^-])eight(?: |-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|8|acre|m2}}$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^y][^-])nine(?: |-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|9|acre|m2}}$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)ten(?: |-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "{{convert|10|acre|m2}}$1");
ArticleText = Regex.Replace(ArticleText, @"(?i)eleven(?: |-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "{{convert|11|acre|m2}}$1");
ArticleText = Regex.Replace(ArticleText, @"(?i)twelve(?: |-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "{{convert|12|acre|m2}}$1");
ArticleText = Regex.Replace(ArticleText, @"(?i)thirteen(?: |-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "{{convert|13|acre|m2}}$1");
ArticleText = Regex.Replace(ArticleText, @"(?i)fourteen(?: |-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "{{convert|14|acre|m2}}$1");
ArticleText = Regex.Replace(ArticleText, @"(?i)fifteen(?: |-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "{{convert|15|acre|m2}}$1");
ArticleText = Regex.Replace(ArticleText, @"(?i)sixteen(?: |-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "{{convert|16|acre|m2}}$1");
ArticleText = Regex.Replace(ArticleText, @"(?i)seventeen(?: |-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "{{convert|17|acre|m2}}$1");
ArticleText = Regex.Replace(ArticleText, @"(?i)eighteen(?: |-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "{{convert|18|acre|m2}}$1");
ArticleText = Regex.Replace(ArticleText, @"(?i)nineteen(?: |-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "{{convert|19|acre|m2}}$1");
ArticleText = Regex.Replace(ArticleText, @"(?i)twenty(?: |-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "{{convert|20|acre|m2}}$1");
ArticleText = Regex.Replace(ArticleText, @"(?i)thirty(?: |-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "{{convert|30|acre|m2}}$1");
ArticleText = Regex.Replace(ArticleText, @"(?i)forty(?: |-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "{{convert|40|acre|m2}}$1");
ArticleText = Regex.Replace(ArticleText, @"(?i)fifty(?: |-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "{{convert|50|acre|m2}}$1");
ArticleText = Regex.Replace(ArticleText, @"(?i)sixty(?: |-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "{{convert|60|acre|m2}}$1");
ArticleText = Regex.Replace(ArticleText, @"(?i)seventy(?: |-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "{{convert|70|acre|m2}}$1");
ArticleText = Regex.Replace(ArticleText, @"(?i)eighty(?: |-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "{{convert|80|acre|m2}}$1");
ArticleText = Regex.Replace(ArticleText, @"(?i)ninety(?: |-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "{{convert|90|acre|m2}}$1");
//acre:singular in full
ArticleText = Regex.Replace(ArticleText, @"(?i)([^y][^-])one(?: |-| |)(?:acre|\[\[acre\]\]|\[\[acre\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|1|acre|m2|sing=on}}$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^y][^-])two(?: |-| |)(?:acre|\[\[acre\]\]|\[\[acre\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|2|acre|m2|sing=on}}$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^y][^-])three(?: |-| |)(?:acre|\[\[acre\]\]|\[\[acre\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|3|acre|m2|sing=on}}$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^y][^-])four(?: |-| |)(?:acre|\[\[acre\]\]|\[\[acre\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|4|acre|m2|sing=on}}$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^y][^-])five(?: |-| |)(?:acre|\[\[acre\]\]|\[\[acre\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|5|acre|m2|sing=on}}$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^y][^-])six(?: |-| |)(?:acre|\[\[acre\]\]|\[\[acre\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|6|acre|m2|sing=on}}$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^y][^-])seven(?: |-| |)(?:acre|\[\[acre\]\]|\[\[acre\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|7|acre|m2|sing=on}}$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^y][^-])eight(?: |-| |)(?:acre|\[\[acre\]\]|\[\[acre\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|8|acre|m2|sing=on}}$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^y][^-])nine(?: |-| |)(?:acre|\[\[acre\]\]|\[\[acre\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|9|acre|m2|sing=on}}$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)ten(?: |-| |)(?:acre|\[\[acre\]\]|\[\[acre\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "{{convert|10|acre|m2|sing=on}}$1");
ArticleText = Regex.Replace(ArticleText, @"(?i)eleven(?: |-| |)(?:acre|\[\[acre\]\]|\[\[acre\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "{{convert|11|acre|m2|sing=on}}$1");
ArticleText = Regex.Replace(ArticleText, @"(?i)twelve(?: |-| |)(?:acre|\[\[acre\]\]|\[\[acre\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "{{convert|12|acre|m2|sing=on}}$1");
ArticleText = Regex.Replace(ArticleText, @"(?i)thirteen(?: |-| |)(?:acre|\[\[acre\]\]|\[\[acre\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "{{convert|13|acre|m2|sing=on}}$1");
ArticleText = Regex.Replace(ArticleText, @"(?i)fourteen(?: |-| |)(?:acre|\[\[acre\]\]|\[\[acre\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "{{convert|14|acre|m2|sing=on}}$1");
ArticleText = Regex.Replace(ArticleText, @"(?i)fifteen(?: |-| |)(?:acre|\[\[acre\]\]|\[\[acre\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "{{convert|15|acre|m2|sing=on}}$1");
ArticleText = Regex.Replace(ArticleText, @"(?i)sixteen(?: |-| |)(?:acre|\[\[acre\]\]|\[\[acre\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "{{convert|16|acre|m2|sing=on}}$1");
ArticleText = Regex.Replace(ArticleText, @"(?i)seventeen(?: |-| |)(?:acre|\[\[acre\]\]|\[\[acre\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "{{convert|17|acre|m2|sing=on}}$1");
ArticleText = Regex.Replace(ArticleText, @"(?i)eighteen(?: |-| |)(?:acre|\[\[acre\]\]|\[\[acre\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "{{convert|18|acre|m2|sing=on}}$1");
ArticleText = Regex.Replace(ArticleText, @"(?i)nineteen(?: |-| |)(?:acre|\[\[acre\]\]|\[\[acre\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "{{convert|19|acre|m2|sing=on}}$1");
ArticleText = Regex.Replace(ArticleText, @"(?i)twenty(?: |-| |)(?:acre|\[\[acre\]\]|\[\[acre\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "{{convert|20|acre|m2|sing=on}}$1");
ArticleText = Regex.Replace(ArticleText, @"(?i)thirty(?: |-| |)(?:acre|\[\[acre\]\]|\[\[acre\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "{{convert|30|acre|m2|sing=on}}$1");
ArticleText = Regex.Replace(ArticleText, @"(?i)forty(?: |-| |)(?:acre|\[\[acre\]\]|\[\[acre\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "{{convert|40|acre|m2|sing=on}}$1");
ArticleText = Regex.Replace(ArticleText, @"(?i)fifty(?: |-| |)(?:acre|\[\[acre\]\]|\[\[acre\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "{{convert|50|acre|m2|sing=on}}$1");
ArticleText = Regex.Replace(ArticleText, @"(?i)sixty(?: |-| |)(?:acre|\[\[acre\]\]|\[\[acre\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "{{convert|60|acre|m2|sing=on}}$1");
ArticleText = Regex.Replace(ArticleText, @"(?i)seventy(?: |-| |)(?:acre|\[\[acre\]\]|\[\[acre\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "{{convert|70|acre|m2|sing=on}}$1");
ArticleText = Regex.Replace(ArticleText, @"(?i)eighty(?: |-| |)(?:acre|\[\[acre\]\]|\[\[acre\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "{{convert|80|acre|m2|sing=on}}$1");
ArticleText = Regex.Replace(ArticleText, @"(?i)ninety(?: |-| |)(?:acre|\[\[acre\]\]|\[\[acre\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "{{convert|90|acre|m2|sing=on}}$1");
//acre:plural
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{3,16}[\d,\.]*)(?: |-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|acre|km2}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d)(?: |-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|acre|m2}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d{0,2}\.\d{0,6})(?: |-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|acre|m2}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d{1,2})(?: |-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|acre|m2}}$3");
//acre:singular
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{3,16}[\d,\.]*)(?: |-| |)(?:acre|\[\[acre\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|acre|km2|sing=on}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d)(?: |-| |)(?:acre|\[\[acre\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|acre|m2|sing=on}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d{0,2}\.\d*)(?: |-| |)(?:acre|\[\[acre\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|acre|m2|sing=on}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d{1,2})(?: |-| |)(?:acre|\[\[acre\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|acre|m2|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+),(\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,\.]*)(?: |-| |)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,\.]*)( |-| |)lbs?.? (thrust|of thrust|force|of force)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2$3lbf $4$5");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*000)(?: |-| |)pounds force([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|lbf|kN}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*)(?: |-| |)pounds force([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|lbf|N}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*000)(?: |-| |)pound force([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|lbf|kN|sing=on}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*)(?: |-| |)pound force([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|lbf|N|sing=on}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*000)(?: |-| |)lbf([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|lbf|kN|abbr=on}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*)(?: |-| |)lbf([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|lbf|abbr=on}}$3");
//pound weight
ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[pound \(weight\)\|([^\]]+)\]\]", "[[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) lbs?([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 lb$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*)(?: |-| |)lb([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|lb|abbr=on}}$3");
//pounds and ounces - plural
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*)(?: |-| |)pounds(?: |-| |)(\d[\d,\.]*)(?: |-| |)ounces?([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|lb|$3|oz|kg}}$4");
//pounds and ounces - singular
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*)(?: |-| |)pound(?: |-| |)(\d[\d,\.]*)(?: |-| |)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,\.]*)(?: |-| |)lbs?\.?,?(?: |-| |)(\d[\d,\.]*)(?: |-| |)oz\.?([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|lb|$3|oz|kg|abbr=on}}$4");
//grain
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*)(?: |-| |)grains([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|gr}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*)(?: |-| |)grain([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|gr|sing=on}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*)(?: |-| |)gr([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|gr|abbr=on}}$3");
//foot and inch: plural
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*)(?: |-| |)feet\.?(?: |-| |)(\d[\d,\.]*)(?: |-| |)(?: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,\.]*)(?: |-| |)foot\.?(?: |-| |)(\d[\d,\.]*)(?: |-| |)(?: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,\.]*)(?: |-| |)ft\.?(?: |-| |)(\d[\d,\.]*)(?: |-| |)(?: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,\.]*)(?: |-| |)(?: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,\.]*)(?: |-| |)(?: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,\.]*)(?: |-| |)(?:ft|\[\[Foot \(unit of length\)\|ft\]\])([^²³·\w\d\(\)\/\\][^\d\(\)\/\\l])", "$1{{convert|$2|ft|m|abbr=on}}$3");
//inch: plural
//'inches of snow' converts to cm
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\Wt""’] )(\d[\d,\.]*)(?: |-| |)inches(?: |-| |)of(?: |-| |)snow([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|in|cm}}$3");
//other inches convert to mm
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\Wt""’] )(\d)(?: |-| |)inches([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|in|mm}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\Wt""’] )(\d?\.\d*)(?: |-| |)inches([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|in|mm}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\Wt""’] )([1-4]\d)(?: |-| |)inches([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|in|mm}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\Wt""’] )([1-4]\d\.\d*)(?: |-| |)inches([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|in|mm}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\Wt""’] )(\d[\d,\.]*)(?: |-| |)inches([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|in|m}}$3");
// inch: plural with number in words
ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] three(?: |-| |)(?:inches|\[\[inches\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (76 mm) $2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] four(?: |-| |)(?:inches|\[\[inches\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (102 mm) $2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] five(?: |-| |)(?:inches|\[\[inches\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (127 mm) $2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] six(?: |-| |)(?:inches|\[\[inches\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (152 mm) $2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] seven(?: |-| |)(?:inches|\[\[inches\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (178 mm) $2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] eight(?: |-| |)(?:inches|\[\[inches\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (203 mm) $2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] nine(?: |-| |)(?:inches|\[\[inches\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (229 mm) $2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] ten(?: |-| |)(?:inches|\[\[inches\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (254 mm) $2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] eleven(?: |-| |)(?:inches|\[\[inches\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (279 mm) $2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] twelve(?: |-| |)(?:inches|\[\[inches\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (305 mm) $2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] thirteen(?: |-| |)(?:inches|\[\[inches\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (330 mm) $2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] fourteen(?: |-| |)(?:inches|\[\[inches\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (356 mm) $2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] fifteen(?: |-| |)(?:inches|\[\[inches\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (381 mm) $2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] sixteen(?: |-| |)(?:inches|\[\[inches\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (406 mm) $2");
//inch: singular
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\Wt""’] )(\d)(?: |-| |)(?:inch|\[\[inch\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|in|mm|sing=on}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\Wt""’] )(\d?\.\d*)(?: |-| |)(?:inch|\[\[inch\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|in|mm|sing=on}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\Wt""’] )([1-4]\d)(?: |-| |)(?:inch|\[\[inch\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|in|mm|sing=on}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\Wt""’] )([1-4]\d\.\d*)(?: |-| |)(?:inch|\[\[inch\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|in|mm|sing=on}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\Wt""’] )(\d[\d,\.]*)(?: |-| |)(?:inch|\[\[inch\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|in|m|sing=on}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|\d+\|(?:in|mm|cm)[^\}]*)\|lk=(?:on|in|out)", "$1");
// inch: singular with number in words
ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] three(?: |-| |)(?:inch|\[\[inch\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (76 mm) $2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] four(?: |-| |)(?:inch|\[\[inch\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (102 mm) $2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] five(?: |-| |)(?:inch|\[\[inch\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (127 mm) $2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] six(?: |-| |)(?:inch|\[\[inch\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (152 mm) $2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] seven(?: |-| |)(?:inch|\[\[inch\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (178 mm) $2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] eight(?: |-| |)(?:inch|\[\[inch\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (203 mm) $2");
//avoid band 'Nine Inch Nails'
ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] nine(?: |-| |)(?:\[\[inch\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (229 mm) $2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] ten(?: |-| |)(?:inch|\[\[inch\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (254 mm) $2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] eleven(?: |-| |)(?:inch|\[\[inch\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (279 mm) $2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] twelve(?: |-| |)(?:inch|\[\[inch\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (305 mm) $2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] thirteen(?: |-| |)(?:inch|\[\[inch\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (330 mm) $2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] fourteen(?: |-| |)(?:inch|\[\[inch\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (356 mm) $2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] fifteen(?: |-| |)(?:inch|\[\[inch\]\]))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 (381 mm) $2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] sixteen(?: |-| |)(?: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) (horsepower|hp|bhp|ihp|shp)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 $2$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)(\d)(?: |-|)horse(?: |-|)power([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 horsepower$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*)(?: |-| |)(?:horsepower|\[\[horsepower\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|hp}}$3");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*)(?: |-| |)(indicated(?: |-| |)horsepower)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|ihp}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*)(?: |-| |)(brake(?: |-| |)horsepower)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1{{convert|$2|bhp}}$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]*)(?: |-| |)(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) rpm([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1 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,\.]*)(?: |-|)([KkMmGgTt]|)(?:bps|bits\/s|b\/s|bits?\/sec)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 $3bit/s$4");
ArticleText = Regex.Replace(ArticleText, @"([^\d\(\)\/\\] )(\d[\d,\.]*)(?: )([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,\.]*)(?: |-|)([KkMmGgTt]|)(?:Bps|bytes?\/s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 $3byte/s$4");
ArticleText = Regex.Replace(ArticleText, @"([^\d\(\)\/\\] )(\d[\d,\.]*)(?: )([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}}");
//rail gauge template
ArticleText = Regex.Replace(ArticleText, @"(?i){{(\d?\d)\s?in}}", "{{convert|$1|in|mm|0|abbr=on}}");
ArticleText = Regex.Replace(ArticleText, @"(?i){{(\d?\d)\s?ft}}", "{{convert|$1|ft|mm|0|abbr=on}}");
ArticleText = Regex.Replace(ArticleText, @"(?i){{(\d?\d)\s?ft\s?(\d?\d)\s?in}}", "{{convert|$1|ft|$2|in|mm|0|abbr=on}}");
ArticleText = Regex.Replace(ArticleText, @"(?i){{(\d?\d)\s?ft\s?(\d?\d\.\d+)\s?in}}", "{{convert|$1|ft|$2|in|mm|0|abbr=on}}");
ArticleText = Regex.Replace(ArticleText, @"(?i)({{railgauge\|[^}]+)\|lk=on(}})", "$1$2");
ArticleText = Regex.Replace(ArticleText, @"(?i){{railgauge\|(\d?\d)\s?in}}", "{{convert|$1|in|mm|0|abbr=on}}");
ArticleText = Regex.Replace(ArticleText, @"(?i){{railgauge\|(\d?\d)\s?ft}}", "{{convert|$1|ft|mm|0|abbr=on}}");
ArticleText = Regex.Replace(ArticleText, @"(?i){{railgauge\|(\d?\d)\s?ft\s?(\d?\d)\s?in}}", "{{convert|$1|ft|$2|in|mm|0|abbr=on}}");
ArticleText = Regex.Replace(ArticleText, @"(?i){{railgauge\|(\d?\d)\s?ft\s?(\d?\d\.\d+)\s?in}}", "{{convert|$1|ft|$2|in|mm|0|abbr=on}}");
//non-US standard gauge commented out because it is mm->in not the other way round
//ArticleText = Regex.Replace(ArticleText, @"(?i){{railgauge\|ussg}}", "{{convert|4|ft|8+1/2|in|mm|0|abbr=on}}");
//US standard gauge commented out until non-US standard gauge resolved
//ArticleText = Regex.Replace(ArticleText, @"(?i){{railgauge\|ussg}}", "{{convert|4|ft|8+1/2|in|mm|0|abbr=on}}");
ArticleText = Regex.Replace(ArticleText, @"(?i){{railgauge\|24}}", "{{convert|2|ft|mm|0|abbr=on}}");
ArticleText = Regex.Replace(ArticleText, @"(?i){{railgauge\|25}}", "{{convert|2|ft|1|in|mm|0|abbr=on}}");
ArticleText = Regex.Replace(ArticleText, @"(?i){{railgauge\|26}}", "{{convert|2|ft|2|in|mm|0|abbr=on}}");
ArticleText = Regex.Replace(ArticleText, @"(?i){{railgauge\|27}}", "{{convert|2|ft|3|in|mm|0|abbr=on}}");
ArticleText = Regex.Replace(ArticleText, @"(?i){{railgauge\|28}}", "{{convert|2|ft|4|in|mm|0|abbr=on}}");
ArticleText = Regex.Replace(ArticleText, @"(?i){{railgauge\|29}}", "{{convert|2|ft|5|in|mm|0|abbr=on}}");
ArticleText = Regex.Replace(ArticleText, @"(?i){{railgauge\|30}}", "{{convert|2|ft|6|in|mm|0|abbr=on}}");
ArticleText = Regex.Replace(ArticleText, @"(?i){{railgauge\|31}}", "{{convert|2|ft|7|in|mm|0|abbr=on}}");
ArticleText = Regex.Replace(ArticleText, @"(?i){{railgauge\|32}}", "{{convert|2|ft|8|in|mm|0|abbr=on}}");
ArticleText = Regex.Replace(ArticleText, @"(?i){{railgauge\|33}}", "{{convert|2|ft|9|in|mm|0|abbr=on}}");
ArticleText = Regex.Replace(ArticleText, @"(?i){{railgauge\|34}}", "{{convert|2|ft|10|in|mm|0|abbr=on}}");
ArticleText = Regex.Replace(ArticleText, @"(?i){{railgauge\|35}}", "{{convert|2|ft|11|in|mm|0|abbr=on}}");
ArticleText = Regex.Replace(ArticleText, @"(?i){{railgauge\|36}}", "{{convert|3|ft|mm|0|abbr=on}}");
ArticleText = Regex.Replace(ArticleText, @"(?i){{railgauge\|37}}", "{{convert|3|ft|1|in|mm|0|abbr=on}}");
ArticleText = Regex.Replace(ArticleText, @"(?i){{railgauge\|38}}", "{{convert|3|ft|2|in|mm|0|abbr=on}}");
ArticleText = Regex.Replace(ArticleText, @"(?i){{railgauge\|39}}", "{{convert|3|ft|3|in|mm|0|abbr=on}}");
ArticleText = Regex.Replace(ArticleText, @"(?i){{railgauge\|40}}", "{{convert|3|ft|4|in|mm|0|abbr=on}}");
ArticleText = Regex.Replace(ArticleText, @"(?i){{railgauge\|41}}", "{{convert|3|ft|5|in|mm|0|abbr=on}}");
ArticleText = Regex.Replace(ArticleText, @"(?i){{railgauge\|42}}", "{{convert|3|ft|6|in|mm|0|abbr=on}}");
ArticleText = Regex.Replace(ArticleText, @"(?i){{railgauge\|48}}", "{{convert|4|ft|mm|0|abbr=on}}");
ArticleText = Regex.Replace(ArticleText, @"(?i){{railgauge\|49}}", "{{convert|4|ft|1|in|mm|0|abbr=on}}");
ArticleText = Regex.Replace(ArticleText, @"(?i){{railgauge\|50}}", "{{convert|4|ft|2|in|mm|0|abbr=on}}");
ArticleText = Regex.Replace(ArticleText, @"(?i){{railgauge\|51}}", "{{convert|4|ft|3|in|mm|0|abbr=on}}");
ArticleText = Regex.Replace(ArticleText, @"(?i){{railgauge\|52}}", "{{convert|4|ft|4|in|mm|0|abbr=on}}");
ArticleText = Regex.Replace(ArticleText, @"(?i){{railgauge\|53}}", "{{convert|4|ft|5|in|mm|0|abbr=on}}");
ArticleText = Regex.Replace(ArticleText, @"(?i){{railgauge\|54}}", "{{convert|4|ft|6|in|mm|0|abbr=on}}");
ArticleText = Regex.Replace(ArticleText, @"(?i){{railgauge\|55}}", "{{convert|4|ft|7|in|mm|0|abbr=on}}");
ArticleText = Regex.Replace(ArticleText, @"(?i){{railgauge\|56}}", "{{convert|4|ft|8|in|mm|0|abbr=on}}");
ArticleText = Regex.Replace(ArticleText, @"(?i){{railgauge\|57}}", "{{convert|4|ft|9|in|mm|0|abbr=on}}");
ArticleText = Regex.Replace(ArticleText, @"(?i){{railgauge\|58}}", "{{convert|4|ft|10|in|mm|0|abbr=on}}");
ArticleText = Regex.Replace(ArticleText, @"(?i){{railgauge\|59}}", "{{convert|4|ft|11|in|mm|0|abbr=on}}");
ArticleText = Regex.Replace(ArticleText, @"(?i){{railgauge\|60}}", "{{convert|5|ft|mm|0|abbr=on}}");
ArticleText = Regex.Replace(ArticleText, @"(?i){{railgauge\|61}}", "{{convert|5|ft|1|in|mm|0|abbr=on}}");
ArticleText = Regex.Replace(ArticleText, @"(?i){{railgauge\|62}}", "{{convert|5|ft|2|in|mm|0|abbr=on}}");
ArticleText = Regex.Replace(ArticleText, @"(?i){{railgauge\|63}}", "{{convert|5|ft|3|in|mm|0|abbr=on}}");
ArticleText = Regex.Replace(ArticleText, @"(?i){{railgauge\|64}}", "{{convert|5|ft|4|in|mm|0|abbr=on}}");
ArticleText = Regex.Replace(ArticleText, @"(?i){{railgauge\|65}}", "{{convert|5|ft|5|in|mm|0|abbr=on}}");
//remove commas from numerical values in convert template
ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|\d+),(\d)", "$1$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|\d+),(\d)", "$1$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|\d+),(\d)", "$1$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|\d+),(\d)", "$1$2");
ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|\d+),(\d)", "$1$2");
//remove leading zeros from convert template
ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|)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,50})\]\]", "$1");
//convert squares and cubes
ArticleText = Regex.Replace(ArticleText, @"({{convert\|[^}]+)\|sqmm\|", "$1|mm2|");
ArticleText = Regex.Replace(ArticleText, @"({{convert\|[^}]+)\|sqcm\|", "$1|cm2|");
ArticleText = Regex.Replace(ArticleText, @"({{convert\|[^}]+)\|sqm\|", "$1|m2|");
ArticleText = Regex.Replace(ArticleText, @"({{convert\|[^}]+)\|sqkm\|", "$1|km2|");
ArticleText = Regex.Replace(ArticleText, @"({{convert\|[^}]+)\|sqmm}", "$1|mm2}");
ArticleText = Regex.Replace(ArticleText, @"({{convert\|[^}]+)\|sqcm}", "$1|cm2}");
ArticleText = Regex.Replace(ArticleText, @"({{convert\|[^}]+)\|sqm}", "$1|m2}");
ArticleText = Regex.Replace(ArticleText, @"({{convert\|[^}]+)\|sqkm}", "$1|km2}");
ArticleText = Regex.Replace(ArticleText, @"({{convert\|[^}]+)\|cumm\|", "$1|mm3|");
ArticleText = Regex.Replace(ArticleText, @"({{convert\|[^}]+)\|cucm\|", "$1|cm3|");
ArticleText = Regex.Replace(ArticleText, @"({{convert\|[^}]+)\|cum\|", "$1|m3|");
ArticleText = Regex.Replace(ArticleText, @"({{convert\|[^}]+)\|cukm\|", "$1|km3|");
ArticleText = Regex.Replace(ArticleText, @"({{convert\|[^}]+)\|cumm}", "$1|mm3}");
ArticleText = Regex.Replace(ArticleText, @"({{convert\|[^}]+)\|cucm}", "$1|cm3}");
ArticleText = Regex.Replace(ArticleText, @"({{convert\|[^}]+)\|cum}", "$1|m3}");
ArticleText = Regex.Replace(ArticleText, @"({{convert\|[^}]+)\|cukm}", "$1|km3}");
ArticleText = Regex.Replace(ArticleText, @"({{convert\|[^}]+)\|sqmi sqkm}", "$1|sqmi km2}");
ArticleText = Regex.Replace(ArticleText, @"({{convert\|[^}]+)\|sqmi sqkm\|", "$1|sqmi km2|");
//delink common units of measurement in convert template
ArticleText = Regex.Replace(ArticleText, @"({{convert\|\d+\|)(mm|mm2|mm3|cm|cm2|cm3|m|m2|m3|km|km2|km3|in|ft|sqft|mi|sqmi)\|lk=on", "$1$2");
ArticleText = Regex.Replace(ArticleText, @"({{convert\|\d+\|)(mm|mm2|mm3|cm|cm2|cm3|m|m2|m3|km|km2|km3|in|ft|sqft|mi|sqmi)(\|\d)\|lk=on", "$1$2$3");
ArticleText = Regex.Replace(ArticleText, @"({{convert\|\d+\|)(mm|mm2|mm3|cm|cm2|cm3|m|m2|m3|km|km2|km3|in|ft|sqft|mi|sqmi)\|(mm|mm2|mm3|cm|cm2|cm3|m|m2|m3|km|km2|km3|in|ft|sqft|mi|sqmi)\|lk=on", "$1$2|$3");
ArticleText = Regex.Replace(ArticleText, @"({{convert\|\d+\|)(mm|mm2|mm3|cm|cm2|cm3|m|m2|m3|km|km2|km3|in|ft|sqft|mi|sqmi)\|(mm|mm2|mm3|cm|cm2|cm3|m|m2|m3|km|km2|km3|in|ft|sqft|mi|sqmi)(\|\d)\|lk=on", "$1$2|$3$4");
return ht.AddBack(ArticleText);
}
//