User:Lightmouse/javascript conversion
From Wikipedia, the free encyclopedia
public string ProcessArticle(string ArticleText, string ArticleTitle, int wikiNamespace, out string Summary, out bool Skip) { Skip = false; Summary = "";
//Identify surprise or 'Easter egg' diversions linking years to 'year in something' articles. Turn them into year links to be dealt with below //removed
// century
ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[((?:first|second|third|fourth|fifth|sixth|seventh|eighth|ninth|tenth|eleventh|twelfth|thirteenth|fourteenth|fifteenth|sixteenth|seventeenth|eighteenth|nineteenth|twentieth|twenty(?: |-)first)(?: |-))century\]\]", "$1century"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[((?:first|second|third|fourth|fifth|sixth|seventh|eighth|ninth|tenth|eleventh|twelfth|thirteenth|fourteenth|fifteenth|sixteenth|seventeenth|eighteenth|nineteenth|twentieth|twenty(?: |-)first)(?: |-))century (AD|BC|CE|BCE)\]\]", "$1century"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(\d{1,2}(?:st|nd|rd|th)(?: |-))century\]\]", "$1century"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(\d{1,2}(?:st|nd|rd|th)(?: |-))centuries\]\]", "$1centuries"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[\d{1,2}(?:st|nd|rd|th)(?: |-)century\|(\d{1,2}(?:st|nd|rd|th))\]\]", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[\d{1,2}(?:st|nd|rd|th)(?: |-)century\|(\d{1,2}(?:st|nd|rd|th)(?: |-))century\]\]", "$1century"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[\d{1,2}(?:st|nd|rd|th)(?: |-)century\|(\d{1,2}(?:st|nd|rd|th)(?: |-))centuries\]\]", "$1centuries"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(\d{1,2}(?:st|nd|rd|th)(?: |-))century (AD|BC|CE|BCE)\]\]", "$1century $2"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[\d{1,2}(?:st|nd|rd|th)(?: |-)century\|(\d{1,2}(?:st|nd|rd|th)(?: |-))century (AD|BC|CE|BCE)\]\]", "$1century $2"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[\d{1,2}(?:st|nd|rd|th)(?: |-)century\|(\d{1,2}(?:st|nd|rd|th)(?: |-))centuries (AD|BC|CE|BCE)\]\]", "$1centuries $2");
// decades and years
ArticleText = Regex.Replace(ArticleText, @"\[\[(\d{1,4})\'?s\]\]", "$1s"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(\d{1,4})\'?(s)? ?(AD|BC|CE|BCE)\]\]", "$1$2 $3"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[\d{1,4}\'?s? ?(?:AD|BC|CE|BCE)\|(\d{1,4})\'?(s)?\]\]", "$1$2"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[\d{1,4}\'?s? ?(?:AD|BC|CE|BCE)\|(\d{1,4})\'?(s)? ?(AD|BC|CE|BCE)\]\]", "$1$2 $3"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[\d{1,4}\'?s?\|(\d{1,4})\'?(s)? ?(AD|BC|CE|BCE)\]\]", "$1$2 $3"); ArticleText = Regex.Replace(ArticleText, @"\[\[\d{1,4}\'?s?\|(\d{1,4})\'?(s)?\]\]", "$1$2"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[\d\d?(?:st|nd|rd|th) centur(?:y|ies)\|(\d{1,4})\'?(s)?\]\]", "$1$2"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[\w{5,12} centur(?:y|ies)\|(\d{1,4})\'?(s)?\]\]", "$1$2");
// solitary day_numbers
ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}\|(\d{1,2}(?:st|nd|rd|th))\]\]", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[\d{1,2} (?:January|February|March|April|May|June|July|August|September|October|November|December)\|(\d{1,2}(?:st|nd|rd|th))\]\]", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(\d{1,2}(?:st|nd|rd|th))\]\]", "$1");
//month+day: removed.
//Identify surprise or 'Easter egg' diversions linking month+years to year articles. Turn them into month+year links to be dealt with below //removed
//Month+day_number "March 7th" -> "March 7"
ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(January|February|March|April|May|June|July|August|September|October|November|December) (\d?\d)(?:st|nd|rd|th)\]\]", "$1 $2"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December) \d?\d)\]\](?:st|nd|rd|th)", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(\d?\d)(?:st|nd|rd|th) (January|February|March|April|May|June|July|August|September|October|November|December)\]\]", "$1 $2");
//Month + year
ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December) \d{3,4})\]\]", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(\d{3,4} (?:January|February|March|April|May|June|July|August|September|October|November|December))\]\]", "$1");
//remove piped years
ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[\d{1,4} in .{1,30}\|(\d{1,4})\]\]", "$1");
//remove piped years from full dates // ArticleText = Regex.Replace(ArticleText, @"(?i)(\[\[\d\d? (?:January|February|March|April|May|June|July|August|September|October|November|December)\]\],? ? ?)\[\[.{1,30}\|(\d{1,4})\]\]", "$1$2"); // ArticleText = Regex.Replace(ArticleText, @"(?i)(\[\[\d\d? (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\]\],? ? ?)\[\[.{1,30}\|(\d{1,4})\]\]", "$1$2"); // ArticleText = Regex.Replace(ArticleText, @"(?i)(\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \d\d?\]\],? ? ?)\[\[.{1,30}\|(\d{1,4})\]\]", "$1$2"); // ArticleText = Regex.Replace(ArticleText, @"(?i)(\[\[(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d\d?\]\],? ? ?)\[\[.{1,30}\|(\d{1,4})\]\]", "$1$2"); // ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[.{1,30}\|(\d{1,4})\]\](,? ?\-? ?\[\[(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d\d?\]\])", "$1$2"); // ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[.{1,30}\|(\d{1,4})\]\](,? ?\-? ?\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \d\d?\]\])", "$1$2"); // ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[.{1,30}\|(\d{1,4})\]\](,? ?\-? ?\[\[\d\d? (?:January|February|March|April|May|June|July|August|September|October|November|December)\]\])", "$1$2"); // ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[.{1,30}\|(\d{1,4})\]\](,? ?\-? ?\[\[\d\d\-\d\d\]\])", "$1$2");
//'present'
ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[Present \(time\)\|(Present)\]\]", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(Present)\]\]", "$1");
//Season
ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(spring \(season\)|summer|winter|autumn)\]\]", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[spring \(season\)\|(spring)\]\]", "$1");
//Identify surprise or 'Easter egg' diversions linking months to year articles.
ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[\d{1,4}#[^\|]{1,30}\|(January|February|March|April|May|June|July|August|September|October|November|December)\]\]", "$1");
//'As of year'
ArticleText = Regex.Replace(ArticleText, @"(?i)(As of )\[\[(\d{1,4})\]\]", "$1$2"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(As of \d{1,4})\]\]", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(as of \d{1,4})\]\]", "$1");
// months
ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(January|February|March|April|May|June|July|August|September|October|November|December)\]\]", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\]\]", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\|(January|February|March|April|May|June|July|August|September|October|November|December)\]\]", "$1");
//Treat 'Sept' (i.e. month abbreviation) differently from 'sept' (i.e. family)
ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(Sept)\]\]", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[January\|(Jan)\]\]", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[February\|(Feb)\]\]", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[March\|(Mar)\]\]", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[April\|(Apr)\]\]", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[May\|(May)\]\]", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[June\|(Jun)\]\]", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[July\|(Jul)\]\]", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[August\|(Aug)\]\]", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[September\|(Sep)\]\]", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[October\|(Oct)\]\]", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[November\|(Nov)\]\]", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[December\|(Dec)\]\]", "$1");
//month piped to number
ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\|(\d{1,4})\]\]", "$1");
//month piped to number
ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\|(\d{1,4})\]\]", "$1");
//Month+day_number piped into number. Preferences do not work. They don't work in sequence because digits in the two dates must be adjacent
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\[]{4})\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December) \d?\d)\]\]( ?\-? ?)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}\|(\d{1,2})\]\]", "$1$2$3$4");
//same again but with ndash or mdash instead of hyphen
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\[]{4})\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December) \d?\d)\]\]( ?&[nm]dash; ?)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}\|(\d{1,2})\]\]", "$1$2$3$4");
//same again but with slash instead of hyphen
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\[]{4})\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December) \d?\d)\]\](\/)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}\|(\d{1,2})\]\]", "$1$2$3$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\[]{4})\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December) \d?\d)\]\]( ?\-? ?)\[\[(\d{1,2})\]\]", "$1$2$3$4");
//same again but with ndash instead of hyphen
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\[]{4})\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December) \d?\d)\]\]( ?&[nm]dash; ?)\[\[(\d{1,2})\]\]", "$1$2$3$4");
//same again but with slash instead of hyphen
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\[]{4})\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December) \d?\d)\]\](\/)\[\[(\d{1,2})\]\]", "$1$2$3$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\[]{4})\[\[(\d?\d) (?:January|February|March|April|May|June|July|August|September|October|November|December)\]\]( ?\-? ?)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}\|(\d{1,2})\]\]", "$1$2$3$4");
//same again but with ndash instead of hyphen
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\[]{4})\[\[(\d?\d) (?:January|February|March|April|May|June|July|August|September|October|November|December)\]\]( ?&[nm]dash; ?)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}\|(\d{1,2})\]\]", "$1$2$3$4");
//same again but with slash instead of hyphen
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\[]{4})\[\[(\d?\d) (?:January|February|March|April|May|June|July|August|September|October|November|December)\]\](\/)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}\|(\d{1,2})\]\]", "$1$2$3$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}\|(\d{1,2})\]\]", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[\d{1,2} (?:January|February|March|April|May|June|July|August|September|October|November|December)\|(\d{1,2})\]\]", "$1");
ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}\|((?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{1,2})\]\]", "$1");
//month+day piped into month+day or vice versa
ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[\d{1,2} (?:January|February|March|April|May|June|July|August|September|October|November|December)\|((?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2})\]\]", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}\|(\d{1,2} (?:January|February|March|April|May|June|July|August|September|October|November|December))\]\]", "$1");
// days of the week in full. Optional plurals
ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(Mondays?|Tuesdays?|Wednesdays?|Thursdays?|Fridays?|Saturdays?|Sundays?)\]\]", "$1");
// days of the week abbreviated. Leave out 'Sun' as potentially valid link to the Sun. Leave out 'SAT' in upper case as potential link to 'Scholastic achievement/aptitude test'.
ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(Mon|Tue|Tues|Wed|Thu|Thur|Thurs|Fri)\]\]", "$1"); ArticleText = Regex.Replace(ArticleText, @"\[\[(Sat)\]\]", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[Mondays?\|(Mondays?|Mon)\]\]", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[Tuesdays?\|(Tuesdays?|Tues?)\]\]", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[Wednesdays?\|(Wednesdays?|Wed)\]\]", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[Thursdays?\|(Thursdays?|Thur?)\]\]", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[Fridays?\|(Fridays?|Fri)\]\]", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[Saturdays?\|(Saturdays?|Sat)\]\]", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[Sundays?\|(Sundays?|Sun)\]\]", "$1");
//4 digit years piped into 2
ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[\d{1,4}\|(\d{1,2})\]\]", "$1");
//year: temporary change to protect accessyear. Undone below at #1
ArticleText = Regex.Replace(ArticleText, @"(?i)(accessyear ?= ?)\[\[(\d{1,4})\]\]", "$1xx$2xx");
//Year: temporary change to protext preference dates - y?y?y?. Needed to handle 'year in' piped links
ArticleText = Regex.Replace(ArticleText, @"(?i)(\[\[\d\d? (?:January|February|March|April|May|June|July|August|September|October|November|December)\]\],? ? ?)\[\[(\d{1,4})\]\]y?y?y?", "$1xx$2xx"); ArticleText = Regex.Replace(ArticleText, @"(?i)(\[\[\d\d? (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\]\],? ? ?)\[\[(\d{1,4})\]\]y?y?y?", "$1xx$2xx"); ArticleText = Regex.Replace(ArticleText, @"(?i)(\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \d\d?\]\],? ? ?)\[\[(\d{1,4})\]\]y?y?y?", "$1xx$2xx"); ArticleText = Regex.Replace(ArticleText, @"(?i)(\[\[(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d\d?\]\],? ? ?)\[\[(\d{1,4})\]\]y?y?y?", "$1xx$2xx"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(\d{1,4})\]\]y?y?y?(,? ?\-? ?\[\[(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d\d?\]\])", "xx$1xx$2"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(\d{1,4})\]\]y?y?y?(,? ?\-? ?\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \d\d?\]\])", "xx$1xx$2"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(\d{1,4})\]\]y?y?y?(,? ?\-? ?\[\[\d\d? (?:January|February|March|April|May|June|July|August|September|October|November|December)\]\])", "xx$1xx$2"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(\d{1,4})\]\]y?y?y?(,? ?\-? ?\[\[\d\d\-\d\d\]\]y?y?y?)", "xx$1xx$2");
//year: now remove unprotected linked years
ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(\d{1,4})\]\]", "$1");
//year: #1. Undo temporary change to protect accessyear and date preference dates
ArticleText = Regex.Replace(ArticleText, @"(?i)xx(\d{1,4})xx", "$1");
//remove flagicons from birth and death ArticleText = Regex.Replace(ArticleText, @"(?i)(birth ?= ?)\{\{flagicon\|[^\}]{1,30}\}\}", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)(death ?= ?)\{\{flagicon\|[^\}]{1,30}\}\}", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)(birth_?place ?= ?)\{\{flagicon\|[^\}]{1,30}\}\}", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)(death_?place ?= ?)\{\{flagicon\|[^\}]{1,30}\}\}", "$1");
//symbol for superscript 2 and 3 //ArticleText = Regex.Replace(ArticleText, @"(?i)2<\/sup>", "²"); //ArticleText = Regex.Replace(ArticleText, @"(?i)3<\/sup>", "³");
// 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,\.]{0,16})(?: |-| |)°F([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 °F (Template:Convert/°C/$2 °F)$3"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(-?\d[\d,\.]{0,16})(?: |-| |)(?:deg|degree|degrees)(?: |-| |)Fahrenheit([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 °F (Template:Convert/°C/$2 °F)$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,\.]{0,16})(?: |-|)m([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 m$3"); //convert "metres" to "m" when in parentheses ArticleText = Regex.Replace(ArticleText, @"(?i)(\(\d[\d,\.]{0,16})(?: |-|)(?:metres|meters|metre|meter)(\))", "$1 m$2"); ArticleText = Regex.Replace(ArticleText, @"(?i)(\(\d[\d,\.]{0,16}) (?:metres|meters|metre|meter)(\))", "$1 m$2"); ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|\d{1,16}\|(?:m|ft)\|[^\}]{0,16})\|lk=(?:on|in|out)", "$1");
//metre per second ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|)(?:m\/second|m\/sec)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 m/s$3"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16}) (?: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{1,16}\|(?:sqm|sqft)[^\}]{0,16})\|lk=(?:on|in|out)", "$1");
// millimetre //delink this common unit ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(milli(?:metres|meters|metre|meter))\]\]", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[milli(?:metres|meters|metre|meter)\|(mm)\]\]", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|)mm([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 mm$3");
// centimetre, cubic centimetre //delink this common unit ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(centi(?:metres|meters|metre|meter))\]\]", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[centi(?:metres|meters|metre|meter)\|(cm)\]\]", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|)(cm|cc)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 $3$4");
// kilometre //delink this common unit ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(kilo(?:metres|meters|metre|meter))\]\]", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[kilo(?:metres|meters|metre|meter)\|(km)\]\]", "$1"); //delink this common unit ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|\d{1,16}\|(?:mi|km)[^\}]{0,16})\|lk=(?:on|in|out)", "$1");
//square kilometre //delink this common unit ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(km²)\]\]", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[square kilomet..\|(km²)\]\]", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\|])sq\.?(?: |-| |)kms?", "$1km²"); ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|\d{1,16})00\|ha", "$1|km2"); ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|\d{1,16})(\d)0\|ha", "$1.$2|km2"); ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|\d{1,16})(\d\d)\|ha", "$1.$2|km2"); ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|\d{1,16}\|sqmi\|)ha", "$1km2"); ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|\d{1,16}\|mi2\|)ha", "$1km2"); ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|\d{1,16}\|(?:sqkm|sqmi|km2|mi2)[^\}]{0,16})\|lk=(?:on|in|out)", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|\d{3,16}\|acre\|)ha", "$1km2");
//kilometre per second ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|)(?:km\/second|km\/sec)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 km/s$3"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16}) (?:km\/second|km\/sec)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 km/s$3");
// kilometre per hour ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|)(?:km\/hr|km\/ph|kph|kmph|kmh)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 km/h$3"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16}) (?:km\/hr|km\/ph|kph|kmph|kmh)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 km/h$3"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|)\[\[(?:km\/hr|km\/ph|kph|kmph|kmh)\]\]([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 km/h$3"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16}) \[\[(?:km\/hr|km\/ph|kph|kmph|kmh)\]\]([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 km/h$3");
//millilitre ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|)(ml)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 $3$4");
// ensure spaces and correct case in kilowatt ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|)kW([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 kW$3");
// ensure spaces and correct case in hertz ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|)Hz([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 Hz$3"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|)kHz([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 kHz$3"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|)GHz([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 GHz$3"); // ensure spaces in megahertz. Must be upper case to avoid clashing with millihertz ArticleText = Regex.Replace(ArticleText, @"([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|)MHz([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 MHz$3");
// frames per second ArticleText = Regex.Replace(ArticleText, @"(?i)frames\/s(\W)", "frame/s$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)frames\/sec(\W)", "frame/s$1");
// kilogram ArticleText = Regex.Replace(ArticleText, @"(?i)kilogrammes", "kilograms"); ArticleText = Regex.Replace(ArticleText, @"(?i)kilogramme", "kilogram"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(kilograms?)\]\]", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[kilograms?\|(kg|kilograms?)\]\]", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|)grammes([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 grams$3"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|)gramme([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 gram$3"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|)(?:kgs?|\[\[kg\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 kg$3"); ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|\d{1,16}\|(?:kg|lb)[^\}]{0,16})\|lk=(?:on|in|out)", "$1");
//foot //delink this common unit ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(foot|feet|ft)\]\]", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[(?:foot|feet|ft|foot)\|(foot|feet|ft)\]\]", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[foot \((?:unit|length|unit of length)\)\|(foot|feet|ft)\]\]", "$1");
//convert "foot" to "ft" when in parentheses ArticleText = Regex.Replace(ArticleText, @"(?i)(\(\d[\d,\.]{0,16})(?: |-|)(?:feet|foot)(\))", "$1 ft$2"); ArticleText = Regex.Replace(ArticleText, @"(?i)(\(\d[\d,\.]{0,16}) (?:feet|foot)(\))", "$1 ft$2");
//remove trailing period when in parentheses ArticleText = Regex.Replace(ArticleText, @"(?i)(\(\d[\d,\.]{0,16})(?: |-|)ft\.(\))", "$1 ft$2"); ArticleText = Regex.Replace(ArticleText, @"(?i)(\(\d[\d,\.]{0,16}) 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,\.]{0,16})(?: |-| |)sq(?: |-| |)ft([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 sq ft (Expression error: Unrecognised punctuation character "$" m²)$3"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-| |)square(?: |-| |)feet([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 square feet (Expression error: Unrecognised punctuation character "$" m²)$3"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-| |)square(?: |-| |)foot([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2-square-foot (Expression error: Unrecognised punctuation character "$" m²)$3"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-| |)thousand(?: |-| |)(?:sq|square)\.?(?: |-| |)ft([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2,000 sq ft (Expression error: Unrecognised punctuation character "$" m²)$3"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-| |)thousand(?: |-| |)(?:sq|square)\.?(?: |-| |)feet([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2,000 square feet (Expression error: Unrecognised punctuation character "$" m²)$3"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-| |)thousand(?: |-| |)(?:sq|square)\.?(?: |-| |)foot([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2,000-square-foot (Expression error: Unrecognised punctuation character "$" m²)$3"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-| |)million(?: |-| |)(?:sq|square)\.?(?: |-| |)ft([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2,000,000 sq ft (Expression error: Unrecognised punctuation character "$" m²)$3"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})\.(\d)(?: |-| |)million(?: |-| |)(?:sq|square)\.?(?: |-| |)ft([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2$3,00,000 sq ft (Expression error: Unrecognised punctuation character "$" m²)$4"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})\.(\d\d)(?: |-| |)million(?: |-| |)(?:sq|square)\.?(?: |-| |)ft([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2$3,0,000 sq ft (Expression error: Unrecognised punctuation character "$" m²)$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-| |)million(?: |-| |)(?:sq|square)\.?(?: |-| |)feet([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2,000,000 square feet (Expression error: Unrecognised punctuation character "$" m²)$3"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})\.(\d)(?: |-| |)million(?: |-| |)(?:sq|square)\.?(?: |-| |)feet([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2$3,00,000 square feet (Expression error: Unrecognised punctuation character "$" m²)$4"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})\.(\d\d)(?: |-| |)million(?: |-| |)(?:sq|square)\.?(?: |-| |)feet([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2$3,0,000 square feet (Expression error: Unrecognised punctuation character "$" m²)$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-| |)million(?: |-| |)(?:sq|square)\.?(?: |-| |)foot([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2,000,000-square-foot (Expression error: Unrecognised punctuation character "$" m²)$3"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})\.(\d)(?: |-| |)million(?: |-| |)(?:sq|square)\.?(?: |-| |)foot([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2$3,00,000-square-foot (Expression error: Unrecognised punctuation character "$" m²)$4"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})\.(\d\d)(?: |-| |)million(?: |-| |)(?:sq|square)\.?(?: |-| |)foot([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2$3,0,000-square-foot (Expression error: Unrecognised punctuation character "$" m²)$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-| |)ft²([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 sq ft (Expression error: Unrecognised punctuation character "$" m²)$3");
//cubic foot ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-| |)trillion(?: |-| |)(?:cu|cubic)\.?(?: |-| |)feet([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1Template:Convert/Tft3$4"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-| |)trillion(?: |-| |)(?:cu|cubic)\.?(?: |-| |)foot([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1Template:Convert/Tft3$4"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-| |)trillion(?: |-| |)(?:cu|cubic)\.?(?: |-| |)ft([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1Template:Convert/Tft3$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-| |)billion(?: |-| |)(?:cu|cubic)\.?(?: |-| |)feet([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1Template:Convert/Gft3$4"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-| |)billion(?: |-| |)(?:cu|cubic)\.?(?: |-| |)foot([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1Template:Convert/Gft3$4"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-| |)billion(?: |-| |)(?:cu|cubic)\.?(?: |-| |)ft([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1Template:Convert/Gft3$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-| |)million(?: |-| |)(?:cu|cubic)\.?(?: |-| |)feet([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2$3 million cubic feet (Expression error: Unrecognised punctuation character "$" m³)$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-| |)million(?: |-| |)(?:cu|cubic)\.?(?: |-| |)foot([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2$3-million-cubic-foot (Expression error: Unrecognised punctuation character "$" m³)$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-| |)million(?: |-| |)(?:cu|cubic)\.?(?: |-| |)ft([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2$3×106 cu ft (Expression error: Unrecognised punctuation character "$" m³)$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-| |)thousand(?: |-| |)(?:cu|cubic)\.?(?: |-| |)feet([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2$3,000 cubic feet (Expression error: Unrecognised punctuation character "$" m³)$4"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-| |)thousand(?: |-| |)(?:cu|cubic)\.?(?: |-| |)foot([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2$3,000-cubic-foot (Expression error: Unrecognised punctuation character "$" m³)$4"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-| |)thousand(?: |-| |)(?:cu|cubic)\.?(?: |-| |)ft([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2$3,000 cu ft (Expression error: Unrecognised punctuation character "$" m³)$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-| |)(?:cu|cubic)\.?(?: |-| |)feet([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2$3 cubic feet (Expression error: Unrecognised punctuation character "$" m³)$4"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-| |)(?:cu|cubic)\.?(?: |-| |)foot([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2$3-cubic-foot (Expression error: Unrecognised punctuation character "$" m³)$4"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(\.[\d,]{1,3})?(?: |-| |)(?:cu|cubic)\.?(?: |-| |)ft([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2$3 cu ft (Expression error: Unrecognised punctuation character "$" m³)$4");
ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-| |)(?:cu|cubic)\.?(?: |-| |)ft³([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 cu ft (Expression error: Unrecognised punctuation character "$" m³)$3");
//cubic foot as bcf, tcf etc ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-| |)bcf([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1Template:Convert/Gft3$3"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-| |)bcf/d([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1Template:Convert/Gft3/d$3"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-| |)tcf([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1Template:Convert/Tft3$3"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-| |)tcf/d([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1Template:Convert/Tft3/d$3");
//convert excessive zeros for cubic foot ArticleText = Regex.Replace(ArticleText, @"(?i)({{convert\|\d{1,16})000000000000\|ft3\|", "$1|Tft3|"); ArticleText = Regex.Replace(ArticleText, @"(?i)({{convert\|\d{1,16})000000000\|ft3\|", "$1|Gft3|"); ArticleText = Regex.Replace(ArticleText, @"(?i)({{convert\|\d{1,16})000000\|ft3\|", "$1|Mft3|");
//convert excessive zeros for cubic feet ArticleText = Regex.Replace(ArticleText, @"(?i)({{convert\|\d{1,16})000000000000\|ft3\|", "$1|Tft3|"); ArticleText = Regex.Replace(ArticleText, @"(?i)({{convert\|\d{1,16})000000000\|ft3\|", "$1|Gft3|"); ArticleText = Regex.Replace(ArticleText, @"(?i)(Template:Convert\)/d", "$1/d|$2/d");
//feet per second ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|)(?:ft\/second|ft\/sec)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 ft/s$3"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16}) (?:ft\/second|ft\/sec)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 ft/s$3"); //feet per second:plural ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-| |)feet per second([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 feet per second (Expression error: Unrecognised punctuation character "$" m/s)$3"); //feet per second:singular ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-| |)foot per second([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2-foot-per-second (Expression error: Unrecognised punctuation character "$" m/s)$3"); //feet per second:abbreviated ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-| |)ft\/s([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 ft/s (Expression error: Unrecognised punctuation character "$" m/s)$3"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-| |)f\/s([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 ft/s (Expression error: Unrecognised punctuation character "$" m/s)$3"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-| |)fps([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 ft/s (Expression error: Unrecognised punctuation character "$" m/s)$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\]\]", "knots"); ArticleText = Regex.Replace(ArticleText, @"(?i)\|kts\]\]", "|knots]]");
//convert knot template to kn to match km ArticleText = Regex.Replace(ArticleText, @"(?i)({{convert\|[\d\.]{1,16})\|knot\|", "$1|kn|");
//nautical mile - rename "miles" as "nautical miles" when followed by knots or conversion code ArticleText = Regex.Replace(ArticleText, @"(?i)(\d)(?: |-| |)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,\.]{0,16})(?: |-| |)nautical(?: |-| |)miles([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 nautical miles (Expression error: Unrecognised punctuation character "$" km)$3"); //nautical mile: plural linked with "s" inside link ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-| |)\[\[nautical(?: |-| |)miles\]\]([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 nautical miles (Expression error: Unrecognised punctuation character "$" km)$3"); //nautical mile: plural linked with "s" outside link ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-| |)\[\[nautical(?: |-| |)mile\]\]s([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 nautical miles (Expression error: Unrecognised punctuation character "$" km)$3"); //nautical mile: singular unlinked ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-| |)nautical(?: |-| |)mile([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2-nautical-mile (Expression error: Unrecognised punctuation character "$" km)$3"); //nautical mile: singular linked ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-| |)\[\[nautical(?: |-| |)mile\]\]([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2-nautical-mile (Expression error: Unrecognised punctuation character "$" km)$3"); //nautical mile: abbreviated ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-| |)(?:\[\[nautical mile\|nmi?\]\]|nmi)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 nmi (Expression error: Unrecognised punctuation character "$" km)$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,\.]{0,16})(?: |-| |)(?:knots|\[\[knot \(speed\)\|(?:knots\]\]|knot\]\]s))([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 knots (Expression error: Unrecognised punctuation character "$" km/h)$3"); //knot - singular ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-| |)(?:knot|\[\[knot \(speed\)\|knot\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2-knot (Expression error: Unrecognised punctuation character "$" km/h)$3"); //knot - abbreviation ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-| |)(?:kts?|\[\[knot \(speed\)\|kts?\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 kn (Expression error: Unrecognised punctuation character "$" km/h)$3");
//mile - lower case to avoid proper names like "Five Mile Road" //delink this common unit ArticleText = Regex.Replace(ArticleText, @"\[\[(mi|mile|miles)\]\]", "$1"); ArticleText = Regex.Replace(ArticleText, @"\[\[(?:mile|miles)\|(mi|mile|miles)\]\]", "$1");
//mile - protect "miles per hour" - undone below ArticleText = Regex.Replace(ArticleText, @"(?i)(miles?) (per)", "$1xx$2"); //miles: plural ArticleText = Regex.Replace(ArticleText, @"([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-| |)(?:miles|\[\[miles\]\]|\[\[mile\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 miles (Expression error: Unrecognised punctuation character "$" km)$3"); //miles: singular ArticleText = Regex.Replace(ArticleText, @"([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-| |)(?:mile|\[\[mile\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2-mile (Expression error: Unrecognised punctuation character "$" km)$3"); //miles: abbreviated ArticleText = Regex.Replace(ArticleText, @"([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-| |)mi([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 mi (Expression error: Unrecognised punctuation character "$" km)$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,\.]{0,16})(?: |-| |)m\.?p\.?h([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 mph (Expression error: Unrecognised punctuation character "$" km/h)$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,\.]{0,16})(?: |-| |)square(?: |-| |)miles([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 square miles (Expression error: Unrecognised punctuation character "$" km²)$3"); // square mile:singular ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-| |)square(?: |-| |)mile([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2-square-mile (Expression error: Unrecognised punctuation character "$" km²)$3"); // square mile:abbreviated ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-| |)sq(?: |-| |)mi([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 sq mi (Expression error: Unrecognised punctuation character "$" km²)$3");
//acre foot:plural ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{3,16}[\d,\.]{0,16})(?: |-| |)acre(?: |-| |)feet([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 acre feet (Expression error: Unrecognised punctuation character "$" m³)$3"); //acre foot:singular ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{3,16}[\d,\.]{0,16})(?: |-| |)acre(?: |-| |)foot([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2-acre-foot (Expression error: Unrecognised punctuation character "$" m³)$3"); //acre foot:abbreviation ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{3,16}[\d,\.]{0,16})(?: |-| |)(?:acre|ac\.?)(?: |-| |)(?:foot|feet|ft)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 acre·ft (Expression error: Unrecognised punctuation character "$" m³)$3");
//acre //acres - temporary change to protect acre feet. changed below ArticleText = Regex.Replace(ArticleText, @"(?i)(acre)(.(?:feet|foot|ft))", "xx$1yy$2"); ArticleText = Regex.Replace(ArticleText, @"(?i)(\d)-(acre)", "$1 $2"); ArticleText = Regex.Replace(ArticleText, @"(?i)(\d)(?: |-| |)surface(?: |-| |)acre", "$1 acre"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-| |)thousand(?: |-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2,000 acres (Expression error: Unrecognised punctuation character "$" km²)$3"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-| |)thousand(?: |-| |)(?:acre|\[\[acre\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2,000-acre (Expression error: Unrecognised punctuation character "$" km²)$3"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})(?: |-| |)million(?: |-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2,000,000 acres (Expression error: Unrecognised punctuation character "$" km²)$3"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})\.(\d)(?: |-| |)million(?: |-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2$3,00,000 acres (Expression error: Unrecognised punctuation character "$" km²)$4"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})\.(\d)(?: |-| |)million(?: |-| |)(?:acre|\[\[acre\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2$3,00,000-acre (Expression error: Unrecognised punctuation character "$" km²)$4"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})\.(\d\d)(?: |-| |)million(?: |-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2$3,0,000 acres (Expression error: Unrecognised punctuation character "$" km²)$4"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{1,16})\.(\d\d)(?: |-| |)million(?: |-| |)(?:acre|\[\[acre\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2$3,0,000-acre (Expression error: Unrecognised punctuation character "$" km²)$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 ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{3,16}[\d,\.]{0,16})(?: |-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 acres (Expression error: Unrecognised punctuation character "$" km²)$3"); //acre:singular ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )([\d,]{3,16}[\d,\.]{0,16})(?: |-| |)(?:acre|\[\[acre\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2-acre (Expression error: Unrecognised punctuation character "$" km²)$3");
//acres - undo temporary change to protect acre feet ArticleText = Regex.Replace(ArticleText, @"(?i)xx(acre)yy", "$1");
//remove commas from numerical values in convert template ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|\d{1,16}),(\d)", "$1$2");
// foot pound ArticleText = Regex.Replace(ArticleText, @"(?i)(\W)lbs?[ -.·•\/]{1,2}ft([^²\w])", "$1ft·lbf$2"); ArticleText = Regex.Replace(ArticleText, @"(?i)(\W)lbs?ft([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1ft·lbf$2"); ArticleText = Regex.Replace(ArticleText, @"(?i)ftlbs?([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "ft·lbf$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)ft\W{1,2}lbs?([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "ft·lbf$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)ftlbs?([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "ft·lbf$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)ft\W{1,2}lbf([^\|])", "ft·lbf$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)ft\W{1,2}lbff", "ft·lbf"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-| |)ft.lbf([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 ft·lbf (Expression error: Unrecognised punctuation character "$" N·m)$3");
//pound force ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})( |-| |)lbs?.? (thrust|of thrust|force|of force)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2$3lbf $4$5"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16}000)(?: |-| |)pounds force([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 pounds-force (Expression error: Unrecognised punctuation character "$" kN)$3"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-| |)pounds force([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 pounds-force (Expression error: Unrecognised punctuation character "$" N)$3"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16}000)(?: |-| |)pound force([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2-pound-force (Expression error: Unrecognised punctuation character "$" kN)$3"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-| |)pound force([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2-pound-force (Expression error: Unrecognised punctuation character "$" N)$3"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16}000)(?: |-| |)lbf([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 lbf (Expression error: Unrecognised punctuation character "$" kN)$3"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-| |)lbf([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 lbf (Expression error: Unrecognised punctuation character "$" N)$3");
//pound weight ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[pound \(weight\)\|([^\]]{1,30})\]\]", "$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,\.]{0,16})(?: |-| |)lb([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 lb (Expression error: Unrecognised punctuation character "$" kg)$3"); //pounds and ounces - plural ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-| |)pounds(?: |-| |)(\d[\d,\.]{0,16})(?: |-| |)ounces?([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 pounds {{convert/and/frnExpression error: Unrecognised punctuation character "$"|$3|ounce|ounces|}} (Expression error: Unrecognised punctuation character "$" kg)$4"); //pounds and ounces - singular ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-| |)pound(?: |-| |)(\d[\d,\.]{0,16})(?: |-| |)ounces?([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2-pound-{{convert/and/fraExpression error: Unrecognised punctuation character "$"|$3}}-ounce (Expression error: Unrecognised punctuation character "$" kg)$4"); //pounds and ounces - abbreviated ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-| |)lbs?\.?,?(?: |-| |)(\d[\d,\.]{0,16})(?: |-| |)oz\.?([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 lb {{convert/and/fraExpression error: Unrecognised punctuation character "$"|$3}} oz (Expression error: Unrecognised punctuation character "$" kg)$4");
//grain ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-| |)grains([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 grains (Expression error: Unrecognised punctuation character "$" g)$3"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-| |)grain([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2-grain (Expression error: Unrecognised punctuation character "$" g)$3"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-| |)gr([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 gr (Expression error: Unrecognised punctuation character "$" g)$3");
//foot and inch: plural ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-| |)feet\.?(?: |-| |)(\d[\d,\.]{0,16})(?: |-| |)(?:in|ins|inch|inches)\.?([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 feet {{convert/and/frnExpression error: Unrecognised punctuation character "$"|$3|inch|inches|n}} (Expression error: Unrecognised punctuation character "$" m)$4"); //foot and inch: singular ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-| |)foot\.?(?: |-| |)(\d[\d,\.]{0,16})(?: |-| |)(?:in|ins|inch|inches)\.?([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2-foot-{{convert/and/fraExpression error: Unrecognised punctuation character "$"|$3}}-inch (Expression error: Unrecognised punctuation character "$" m)$4"); //foot and inch: abbreviated ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-| |)ft\.?(?: |-| |)(\d[\d,\.]{0,16})(?: |-| |)(?:in|ins|inch|inches)\.?([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 ft {{convert/and/fraExpression error: Unrecognised punctuation character "$"|$3}} in (Expression error: Unrecognised punctuation character "$" m)$4");
//foot (again). Parsed after "foot per second" and "foot pound" //foot: plural ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-| |)(?:feet|\[\[Foot \(unit of length\)\|feet\]\])([^²³·\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 feet (Expression error: Unrecognised punctuation character "$" m)$3"); //foot: singular ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-| |)(?:foot|\[\[Foot \(unit of length\)\|foot\]\])([^²³·\w\d\(\)\/\\][^\d\(\)\/\\p])", "$1$2-foot (Expression error: Unrecognised punctuation character "$" m)$3"); //foot: abbreviated ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-| |)(?:ft|\[\[Foot \(unit of length\)\|ft\]\])([^²³·\w\d\(\)\/\\][^\d\(\)\/\\l])", "$1$2 ft (Expression error: Unrecognised punctuation character "$" m)$3");
//inch: plural //'inches of snow' converts to cm ArticleText = Regex.Replace(ArticleText, @"(?i)([^\Wt""’] )(\d[\d,\.]{0,16})(?: |-| |)inches(?: |-| |)of(?: |-| |)snow([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 inches (Expression error: Unrecognised punctuation character "$" cm)$3"); //other inches convert to mm ArticleText = Regex.Replace(ArticleText, @"(?i)([^\Wt""’] )(\d[\d,\.]{0,16})(?: |-| |)inches([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 inches (Expression error: Unrecognised punctuation character "$" mm)$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[\d,\.]{0,16})(?: |-| |)(?:inch|\[\[inch\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2-inch (Expression error: Unrecognised punctuation character "$" mm)$3"); ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|\d{1,16}\|(?:in|mm|cm)[^\}]{0,16})\|lk=(?:on|in|out)", "$1"); // inch: singular with number in words ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] three(?: |-| |)(?: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"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^ty] nine(?: |-| |)(?:inch|\[\[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,\.]{0,16})(?: |-| |)(?:horsepower|\[\[horsepower\]\])([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 horsepower (Expression error: Unrecognised punctuation character "$" kW)$3"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-| |)(indicated(?: |-| |)horsepower)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 indicated horsepower (Expression error: Unrecognised punctuation character "$" kW)$4"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-| |)(brake(?: |-| |)horsepower)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 brake horsepower (Expression error: Unrecognised punctuation character "$" kW)$4"); ArticleText = Regex.Replace(ArticleText, @"(?i)([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-| |)(hp|bhp|ihp|shp)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1Template:Convert/$3$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,\.]{0,16})(?: |-|)([KkMmGgTt]|)(?:bps|bits\/s|b\/s|bits?\/sec)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 $3bit/s$4"); ArticleText = Regex.Replace(ArticleText, @"([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: )([KkMmGgTt]|)(?:bps|bits\/s|b\/s|bits?\/sec)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 $3bit/s$4");
// bytes per second ArticleText = Regex.Replace(ArticleText, @"([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: |-|)([KkMmGgTt]|)(?:Bps|bytes?\/s)([^²³\w\d\(\)\/\\][^\d\(\)\/\\])", "$1$2 $3byte/s$4"); ArticleText = Regex.Replace(ArticleText, @"([^\d\(\)\/\\] )(\d[\d,\.]{0,16})(?: )([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)Template:Mi to km\", "$1 miles (Expression error: Unrecognised punctuation character "$" km)"); ArticleText = Regex.Replace(ArticleText, @"(?i)Template:Mi to km\}", "$1 miles (Expression error: Unrecognised punctuation character "$" km)"); ArticleText = Regex.Replace(ArticleText, @"(?i)Template:Mi2 to km2\", "$1 miles (Expression error: Unrecognised punctuation character "$" km)"); ArticleText = Regex.Replace(ArticleText, @"(?i)Template:Mi2 to km2\}", "$1 miles (Expression error: Unrecognised punctuation character "$" km)");
//remove commas from numerical values in convert template ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|\d{1,16}),(\d)", "$1$2"); ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|\d{1,16}),(\d)", "$1$2"); ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|\d{1,16}),(\d)", "$1$2"); ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|\d{1,16}),(\d)", "$1$2"); ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|\d{1,16}),(\d)", "$1$2");
//remove leading zeros from convert template ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|)0(\d)", "$1$2"); ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|)0(\d)", "$1$2"); ArticleText = Regex.Replace(ArticleText, @"(?i)({convert\|)0(\d)", "$1$2");
//Remove surprise or "Easter egg" diversions linking unit name to orders of magnitude articles ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[1 ?_?E ?[\-\+]?\d{1,2} ?..?\|([^\]]{1,50})\]\]", "$1"); ArticleText = Regex.Replace(ArticleText, @"(?i)\[\[Orders of magnitude \([^\)]{1,30}\)\|([^\]]{1,50})\]\]", "$1");
return ArticleText; }