Jump to content

User:MJCdetroit/monobook.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// [[User:Lupin/popups.js]]

mw.loader.load(
             'https://en.wikipedia.org/w/index.php?title=User:Lupin/popups.js'
             + '&action=raw&ctype=text/javascript&dontcountme=s');


//Create 'winc' function:

function winc(s) {
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=' + s
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
}


//'winc' function allows buttons to be added toolbar
winc('User:Omegatron/monobook.js/addlink.js');
 
function dates() {
    var txt = document.editform.wpTextbox1;
 
    //Identify surprise or 'Easter egg' diversions linking years to 'year in something' articles. Turn them into year links to be dealt with below
txt.value=txt.value.replace(/\[\[\d{1,4}s?\sin\s[^\|]{1,30}\|(\d{1,4}s?)\]\]/gi, '\[\[$1\]\]');
 
    // century
txt.value=txt.value.replace(/\[\[((?:first|second|third|fourth|fifth|sixth|seventh|eighth|ninth|tenth|eleventh|twelfth|thirteenth|fourteenth|fifteenth|sixteenth|seventeenth|eighteenth|nineteenth|twentieth|twenty[ \-]first))[ \-]century\]\]/gi, '$1 century');
txt.value=txt.value.replace(/\[\[((?:first|second|third|fourth|fifth|sixth|seventh|eighth|ninth|tenth|eleventh|twelfth|thirteenth|fourteenth|fifteenth|sixteenth|seventeenth|eighteenth|nineteenth|twentieth|twenty[ \-]first))[ \-]century\s(AD|BC|CE|BCE)\]\]/gi, '$1 century');
txt.value=txt.value.replace(/\[\[(\d{1,2}(?:st|nd|rd|th))[ \-]century\]\]/gi, '$1 century');
txt.value=txt.value.replace(/\[\[\d{1,2}(?:st|nd|rd|th)[ \-]century\|(\d{1,2}(?:st|nd|rd|th))\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[\d{1,2}(?:st|nd|rd|th)[ \-]century\|(\d{1,2}(?:st|nd|rd|th))[ \-]century\]\]/gi, '$1 century');
txt.value=txt.value.replace(/\[\[\d{1,2}(?:st|nd|rd|th)[ \-]century\|(\d{1,2}(?:st|nd|rd|th))[ \-]centuries\]\]/gi, '$1 centuries');
txt.value=txt.value.replace(/\[\[(\d{1,2}(?:st|nd|rd|th))[ \-]century\s(AD|BC|CE|BCE)\]\]/gi, '$1 century $2');
txt.value=txt.value.replace(/\[\[\d{1,2}(?:st|nd|rd|th)[ \-]century\|(\d{1,2}(?:st|nd|rd|th))[ \-]century\s(AD|BC|CE|BCE)\]\]/gi, '$1 century $2');
txt.value=txt.value.replace(/\[\[\d{1,2}(?:st|nd|rd|th)[ \-]century\|(\d{1,2}(?:st|nd|rd|th))[ \-]centuries\s(AD|BC|CE|BCE)\]\]/gi, '$1 centuries $2');
    //century but avoiding '20th Century Fox'
txt.value=txt.value.replace(/(\d(?:st|nd|rd))[ \-]Century/gi, '$1 century');
txt.value=txt.value.replace(/([456789]th)[ \-]Century/gi, '$1 century');
txt.value=txt.value.replace(/(0th)[ \-]Century(.[^F])/gi, '$1 century$2');
 
    // decades and years
txt.value=txt.value.replace(/\[\[(\d{1,4})\'?s\]\]/gi, '$1s');
txt.value=txt.value.replace(/\[\[(\d{1,4})\'?(s)?\s?(AD|BC|CE|BCE)\]\]/gi, '$1$2 $3');
txt.value=txt.value.replace(/\[\[\d{1,4}\'?s?\s?(?:AD|BC|CE|BCE)\|(\d{1,4})\'?(s)?\]\]/gi, '$1$2');
txt.value=txt.value.replace(/\[\[\d{1,4}\'?s?\s?(?:AD|BC|CE|BCE)\|(\d{1,4})\'?(s)?\s?(AD|BC|CE|BCE)\]\]/gi, '$1$2 $3');
txt.value=txt.value.replace(/\[\[\d{1,4}\'?s?\|(\d{1,4})\'?(s)?\s?(AD|BC|CE|BCE)\]\]/gi, '$1$2 $3');
txt.value=txt.value.replace(/\[\[\d{1,4}\'?s?\|(\d{1,4})\'?(s)?\]\]/gi, '$1$2');
txt.value=txt.value.replace(/\[\[\d\d?(?:st|nd|rd|th)\scentur(?:y|ies)\|(\d{1,4})\'?(s)?\]\]/gi, '$1$2');
txt.value=txt.value.replace(/\[\[\w{5,12}\scentur(?:y|ies)\|(\d{1,4})\'?(s)?\]\]/gi, '$1$2');
 
    // solitary day_numbers
txt.value=txt.value.replace(/\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}\|(\d{1,2}(?:th|st|nd|rd))\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[\d{1,2} (?:January|February|March|April|May|June|July|August|September|October|November|December)\|(\d{1,2}(?:th|st|nd|rd))\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[(\d{1,2}(?:st|nd|rd|th))\]\]/gi, '$1');
 
    //month+day: remove incorrect trailing space
txt.value=txt.value.replace(/(\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d\d?)\s(\]\])/gi,'$1$2');
 
    //month+year
    //Identify surprise or 'Easter egg' diversions linking month+years to year articles. Turn them into month+year links to be dealt with below
txt.value=txt.value.replace(/\[\[\d{1,4}#[^\|]{1,30}\|((?:January|February|March|April|May|June|July|August|September|October|November|December) \d{3,4})\]\]/gi, '\[\[$1\]\]');
txt.value=txt.value.replace(/\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December) \d{3,4})\]\]/gi, '$1');
 
 
    //year: temporary change to protect accessyear. Undone below at #1
txt.value=txt.value.replace(/(accessyear\s?=\s?)\[\[(\d{1,4})\]\]/gi, '$1xx$2xx');
 
    //Year: temporary change to protext preference dates - y?y?y?. Needed to handle 'year in' piped links
txt.value=txt.value.replace(/(\[\[\d\d?\s(?:January|February|March|April|May|June|July|August|September|October|November|December)\]\],?\s?\s?)\[\[(\d{1,4})\]\]y?y?y?/gi,'$1xx$2xx');
txt.value=txt.value.replace(/(\[\[\d\d?\s(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\]\],?\s?\s?)\[\[(\d{1,4})\]\]y?y?y?/gi,'$1xx$2xx');
txt.value=txt.value.replace(/(\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d\d?\]\],?\s?\s?)\[\[(\d{1,4})\]\]y?y?y?/gi,'$1xx$2xx');
txt.value=txt.value.replace(/(\[\[(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d\d?\]\],?\s?\s?)\[\[(\d{1,4})\]\]y?y?y?/gi,'$1xx$2xx');
 
txt.value=txt.value.replace(/\[\[(\d{1,4})\]\]y?y?y?(,?\s?\-?\s?\[\[(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d\d?\]\])/gi,'xx$1xx$2');
txt.value=txt.value.replace(/\[\[(\d{1,4})\]\]y?y?y?(,?\s?\-?\s?\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d\d?\]\])/gi,'xx$1xx$2');
txt.value=txt.value.replace(/\[\[(\d{1,4})\]\]y?y?y?(,?\s?\-?\s?\[\[\d\d?\s(?:January|February|March|April|May|June|July|August|September|October|November|December)\]\])/gi,'xx$1xx$2');
 
txt.value=txt.value.replace(/\[\[(\d{1,4})\]\]y?y?y?(,?\s?\-?\s?\[\[\d\d\-\d\d\]\]y?y?y?)/gi,'xx$1xx$2');
 
    //year: now remove unprotected linked years
txt.value=txt.value.replace(/\[\[(\d{1,4})\]\]/gi, '$1');
 
    //year: #1. Undo temporary change to protect accessyear and date preference dates
txt.value=txt.value.replace(/xx(\d{1,4})xx/gi, '\[\[$1\]\]');
}
 
 
 
function formatgeneral() {
    var txt = document.editform.wpTextbox1;
 
   //remove flagicons from birth and death
txt.value=txt.value.replace(/(birth\s?=\s?)\{\{flagicon\|[^\}]{1,30}\}\}/gi, '$1');
txt.value=txt.value.replace(/(death\s?=\s?)\{\{flagicon\|[^\}]{1,30}\}\}/gi, '$1');
txt.value=txt.value.replace(/(birth_place\s?=\s?)\{\{flagicon\|[^\}]{1,30}\}\}/gi, '$1');
txt.value=txt.value.replace(/(death_place\s?=\s?)\{\{flagicon\|[^\}]{1,30}\}\}/gi, '$1');
 
   //fix captalisation in headings
txt.value=txt.value.replace(/\n(={2,3})(\s?)See\sAlso\s?={2,3}/g, '\n$1$2See also$2$1')
txt.value=txt.value.replace(/\n(={2,3})(\s?)Further\sReading\s?={2,3}/g, '\n$1$2Further reading$2$1') 
txt.value=txt.value.replace(/\n(={2,3})(\s?)Works\sCited\s?={2,3}/g, '\n$1$2Works cited$2$1')
txt.value=txt.value.replace(/\n(={2,3})(\s?)External\slink(s?)\s?={2,3}/g, '\n$1$2External link$3$2$1')
txt.value=txt.value.replace(/\n(={2,3})(\s?)Foot\s[Nn]otes\s?={2,3}/g, '\n$1$2Footnotes$2$1')
 
    //symbol for 'times'
txt.value=txt.value.replace(/&times;/gi, '×');
 
    //symbol for superscript 2 and 3
txt.value=txt.value.replace(/<sup>2<\/sup>/gi, '²');
txt.value=txt.value.replace(/<sup>3<\/sup>/gi, '³');
 
    //Attempt to deal with naval infobox
txt.value=txt.value.replace(/General\sCharacteristics/g, 'General characteristics');
 
    //turn letter 'x' into symbol '×'
txt.value=txt.value.replace(/(\d)\sx\s(\d{1,3})\sin\s\(/gi, '$1 × $2 in (');
txt.value=txt.value.replace(/(\d)\sx\s(\d{1,3})\sinch\s/gi, '$1 × $2 inch ');
 
    //expand torpedo tube abbreviation
txt.value=txt.value.replace(/inch\st\.?t\.?/g, 'inch torpedo tubes');
 
// inch guns and torpedos to mm
txt.value=txt.value.replace(/\s(\d{1,3}\.?\d?)(?:\s|-|&nbsp;)inch(?:\s|-|&nbsp;)gun/gi, ' \{\{convert|$1|in|mm|sing=on\}\} gun');
txt.value=txt.value.replace(/\s(\d{1,3}\.?\d?)(?:\s|-|&nbsp;)inch(?:\s|-|&nbsp;)main\sgun/gi, ' \{\{convert|$1|in|mm|sing=on\}\} main gun');
txt.value=txt.value.replace(/\s(\d{1,3}\.?\d?)(?:\s|-|&nbsp;)inch(?:\s|-|&nbsp;)deck\sgun/gi, ' \{\{convert|$1|in|mm|sing=on\}\} deck gun');
txt.value=txt.value.replace(/\s(\d\d)(?:\s|-|&nbsp;)inch(?:\s|-|&nbsp;)torpedo/gi, ' \{\{convert|$1|in|mm|sing=on\}\} torpedo');
txt.value=txt.value.replace(/([^y]\sthree(?:\s|-|&nbsp;)inch)(?:\s|-|&nbsp;)gun/gi, '$1 (76&nbsp;mm) gun');
txt.value=txt.value.replace(/([^y]\sfour(?:\s|-|&nbsp;)inch)(?:\s|-|&nbsp;)gun/gi, '$1 (102&nbsp;mm) gun');
txt.value=txt.value.replace(/([^y]\sfive(?:\s|-|&nbsp;)inch)(?:\s|-|&nbsp;)gun/gi, '$1 (127&nbsp;mm) gun');
txt.value=txt.value.replace(/([^y]\ssix(?:\s|-|&nbsp;)inch)(?:\s|-|&nbsp;)gun/gi, '$1 (152&nbsp;mm) gun');
txt.value=txt.value.replace(/([^y]\sseven(?:\s|-|&nbsp;)inch)(?:\s|-|&nbsp;)gun/gi, '$1 (178&nbsp;mm) gun');
txt.value=txt.value.replace(/([^y]\seight(?:\s|-|&nbsp;)inch)(?:\s|-|&nbsp;)gun/gi, '$1 (203&nbsp;mm) gun');
txt.value=txt.value.replace(/([^y]\snine(?:\s|-|&nbsp;)inch)(?:\s|-|&nbsp;)gun/gi, '$1 (229&nbsp;mm) gun');
txt.value=txt.value.replace(/(\sten(?:\s|-|&nbsp;)inch)(?:\s|-|&nbsp;)gun/gi, '$1 (254&nbsp;mm) gun');
txt.value=txt.value.replace(/(\seleven(?:\s|-|&nbsp;)inch)(?:\s|-|&nbsp;)gun/gi, '$1 (279&nbsp;mm) gun');
txt.value=txt.value.replace(/(\stwelve(?:\s|-|&nbsp;)inch)(?:\s|-|&nbsp;)gun/gi, '$1 (305&nbsp;mm) gun');
txt.value=txt.value.replace(/(\sthirteen(?:\s|-|&nbsp;)inch)(?:\s|-|&nbsp;)gun/gi, '$1 (330&nbsp;mm) gun');
txt.value=txt.value.replace(/(\sfourteen(?:\s|-|&nbsp;)inch)(?:\s|-|&nbsp;)gun/gi, '$1 (356&nbsp;mm) gun');
txt.value=txt.value.replace(/(\sfifteen(?:\s|-|&nbsp;)inch)(?:\s|-|&nbsp;)gun/gi, '$1 (381&nbsp;mm) gun');
txt.value=txt.value.replace(/(\ssixteen(?:\s|-|&nbsp;)inch)(?:\s|-|&nbsp;)gun/gi, '$1 (406&nbsp;mm) gun');
 
 
 
    // Convert degree symbols into ° symbol, ensure preceding space
txt.value=txt.value.replace(/&deg;/g, '°');
txt.value=txt.value.replace(/º/g, '°');
 
    // Celsius spelling errors
txt.value=txt.value.replace(/celsius/gi, 'Celsius');
txt.value=txt.value.replace(/celcius/gi, 'Celsius');
    //Fix common naming error (be careful with this one)
txt.value=txt.value.replace(/centigrade/gi, 'Celsius');
 
    //Celsius or Fahrenheit
txt.value=txt.value.replace(/°\s([CF])/g, '°$1');
txt.value=txt.value.replace(/°&nbsp;([CF])/g, '°$1');
txt.value=txt.value.replace(/°\s?(celsius)/gi, '°C');
txt.value=txt.value.replace(/°&nbsp;(celsius)/gi, '°C');
txt.value=txt.value.replace(/(\d)\s?(°[CF])/g, '$1 $2');
txt.value=txt.value.replace(/deg[^\(]([CF])/gi, '°$1');
txt.value=txt.value.replace(/deg\s?([CF])/gi, '°$1');
txt.value=txt.value.replace(/deg&nbsp;([CF])/gi, '°$1');
txt.value=txt.value.replace(/deg\.?\s?([CF])/gi, '°$1');
txt.value=txt.value.replace(/degrees?\s([CF])(\W)/gi, '°$1$2');
txt.value=txt.value.replace(/degrees?&nbsp;([CF])(\W)/gi, '°$1$2');
txt.value=txt.value.replace(/(\d)\s?°&nbsp;([CF])/g, '$1 °$2');
txt.value=txt.value.replace(/(\d)°([CF])/g, '$1 °$2');
txt.value=txt.value.replace(/(\d)°\[\[/g, '$1 °[[');
txt.value=txt.value.replace(/(\d)°&nbsp;(\[\[[CF])/gi, '$1&nbsp;°$2');
txt.value=txt.value.replace(/(\d)(\[\[Celsius|°C\]\])/gi, '$1 $2');
txt.value=txt.value.replace(/(\d)(\[\[Fahrenheit|°F\]\])/gi, '$1 $2');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(-?\d[\d,\.]{0,16})(?:\s|-|&nbsp;|)°?F([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1\{\{convert|$2|°F|°C|abbr=on\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(-?\d[\d,\.]{0,16})(?:\s|-|&nbsp;|)(?:deg|degree|degrees)(?:\s|-|&nbsp;|)Fahrenheit([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|°F|°C\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(-?\d[\d,\.]{0,16})(?:\s|-|&nbsp;|)°?C([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1\{\{convert|$2|°C|°F|abbr=on\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(-?\d[\d,\.]{0,16})(?:\s|-|&nbsp;|)(?:deg|degree|degrees)(?:\s|-|&nbsp;|)Celsius([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|°C|°F\}\}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(-?\d[\d,\.]{0,16})(?:\s|-|&nbsp;|)(?:deg|degree|degrees)(?:\s|-|&nbsp;|)Centigrade([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1\{\{convert|$2|°C|°F\}\}$3'); 
 
    // Convert &sup to superscript
txt.value=txt.value.replace(/&sup2;/g, '²');
txt.value=txt.value.replace(/&sup3;/g, '³');
 
    // Convert micro symbol to actual micro symbol, make sure it's spaced
txt.value=txt.value.replace(/(\d)\s?(&mu;|μ|&micro;)(g|s|m|A|K|mol|cd|rad|sr|Hz|N|J|W|Pa|lm|lx|C|V|Ω|F|Wb|T|H|S|Bq|Gy|Sv|kat|M)(\W)/g, '$1 µ$3$4');
 
    //metre
    //space before 'm' only when lower case
txt.value=txt.value.replace(/\[\[(metre)\]\]/gi, '$1');
txt.value=txt.value.replace(/([^£$]{9}\d)\s?m(\s)/g, '$1 m$2');
txt.value=txt.value.replace(/([^£$]{9}\d)\-m(\s)/g, '$1 m$2');
txt.value=txt.value.replace(/(\d)\s?sq\.?\s?m(\s)/gi, '$1 m²$2');
txt.value=txt.value.replace(/(\d)\-?sq\-?m(\s)/gi, '$1 m²$2');
txt.value=txt.value.replace(/m²\.\)/gi, 'm²)');
txt.value=txt.value.replace(/\smetres?\)/gi, ' m)');
txt.value=txt.value.replace(/\smeters?\)/gi, ' m)');
txt.value=txt.value.replace(/([\|\=\>][\s\d\.]{1,9})meters?(\s{1,3}\()/gi, '$1m$2');
txt.value=txt.value.replace(/([\|\=\>][\s\d\.]{1,9})metres?(\s{1,3}\()/gi, '$1m$2');
txt.value=txt.value.replace(/([\|\=\>][\s\d\.]{1,9}&nbsp;)meters?((&nbsp;|\s{1,3})\()/gi, '$1m$2');
txt.value=txt.value.replace(/([\|\=\>][\s\d\.]{1,9}&nbsp;)metres?((&nbsp;|\s{1,3})\()/gi, '$1m$2');


//metres: plural (British Imperial spelling)
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(000),?(000)(?:\s|-|&nbsp;)metres([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m|ft|\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}00),?(000)(?:\s|-|&nbsp;)metres([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m|ft|\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}0),?(000)(?:\s|-|&nbsp;)metres([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m|ft|\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)metres([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m|ft|\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)metres([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m|ft|\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)metres([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m|ft|\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)metres([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m|ft|\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d)(?:\s|-|&nbsp;)metres([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4$5|m|ft|\}\}$6');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d\d)(?:\s|-|&nbsp;)metres([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4$5|m|ft|\}\}$6');
 
//metres: singular (British Imperial spelling)
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(000),?(000)(?:\s|-|&nbsp;)metre(\s[^\(\/])/gi, '$1\{\{convert|$2$3$4|m|ft|sing=on\}\}$5');
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(\d{1,3}00),?(000)(?:\s|-|&nbsp;)metre(\s[^\(\/])/gi, '$1\{\{convert|$2$3$4|m|ft|sing=on\}\}$5');
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(\d{1,3}0),?(000)(?:\s|-|&nbsp;)metre(\s[^\(\/])/gi, '$1\{\{convert|$2$3$4|m|ft|sing=on\}\}$5');
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)metre(\s[^\(\/])/gi, '$1\{\{convert|$2$3$4|m|ft|sing=on\}\}$5');
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)metre(\s[^\(\/])/gi, '$1\{\{convert|$2$3$4|m|ft|sing=on\}\}$5');
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)metre(\s[^\(\/])/gi, '$1\{\{convert|$2$3$4|m|ft|sing=on\}\}$5');
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)metre(\s[^\(\/])/gi, '$1\{\{convert|$2$3$4|m|ft|sing=on\}\}$5');
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)metre(\s[^\(\/])/gi, '$1\{\{convert|$2$3$4|m|ft|sing=on\}\}$5');
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d)(?:\s|-|&nbsp;)metre(\s[^\(\/])/gi, '$1\{\{convert|$2$3$4$5|m|ft|sing=on\}\}$6');
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d\d)(?:\s|-|&nbsp;)metre(\s[^\(\/])/gi, '$1\{\{convert|$2$3$4$5|m|ft|sing=on\}\}$6');
//metres: abbreviated
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(000),?(000)(?:\s|-|&nbsp;)m(\.|\,|\s[^\(\/]{2})/gi, '$1\{\{convert|$2$3$4|m|ft|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(\d{1,3}00),?(000)(?:\s|-|&nbsp;)m(\.|\,|\s[^\(\/]{2})/gi, '$1\{\{convert|$2$3$4|m|ft|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(\d{1,3}0),?(000)(?:\s|-|&nbsp;)m(\.|\,|\s[^\(\/]{2})/gi, '$1\{\{convert|$2$3$4|m|ft|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)m(\.|\,|\s[^\(\/]{2})/gi, '$1\{\{convert|$2$3$4|m|ft|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)m(\.|\,|\s[^\(\/]{2})/gi, '$1\{\{convert|$2$3$4|m|ft|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)m(\.|\,|\s[^\(\/]{2})/gi, '$1\{\{convert|$2$3$4|m|ft|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)m(\.|\,|\s[^\(\/]{2})/gi, '$1\{\{convert|$2$3$4|m|ft|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d)(?:\s|-|&nbsp;)m(\.|\,|\s[^\(\/]{2})/gi, '$1\{\{convert|$2$3$4$5|m|ft|abbr=on\}\}$6');
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d\d)(?:\s|-|&nbsp;)m(\.|\,|\s[^\(\/]{2})/gi, '$1\{\{convert|$2$3$4$5|m|ft|abbr=on\}\}$6');
//metres: in full (British Imperial spelling)
txt.value=txt.value.replace(/([^y]\sone(?:\s|-|&nbsp;)metre?)(\s[^\(\)]{2})/gi, '$1 (3.2&nbsp;ft)$2');
txt.value=txt.value.replace(/([^y]\stwo(?:\s|-|&nbsp;)metres?)(\s[^\(\)]{2})/gi, '$1 (6.5&nbsp;ft)$2');
txt.value=txt.value.replace(/([^y]\sthree(?:\s|-|&nbsp;)metres?)(\s[^\(\)]{2})/gi, '$1 (10&nbsp;ft)$2');
txt.value=txt.value.replace(/([^y]\sfour(?:\s|-|&nbsp;)metres?)(\s[^\(\)]{2})/gi, '$1 (13&nbsp;ft)$2');
txt.value=txt.value.replace(/([^y]\sfive(?:\s|-|&nbsp;)metres?)(\s[^\(\)]{2})/gi, '$1 (16.4&nbsp;ft)$2');
txt.value=txt.value.replace(/([^y]\ssix(?:\s|-|&nbsp;)metres?)(\s[^\(\)]{2})/gi, '$1 (19.7&nbsp;ft)$2');
txt.value=txt.value.replace(/([^y]\sseven(?:\s|-|&nbsp;)metres?)(\s[^\(\)]{2})/gi, '$1 (23&nbsp;ft)$2');
txt.value=txt.value.replace(/([^y]\seight(?:\s|-|&nbsp;)metres?)(\s[^\(\)]{2})/gi, '$1 (26.2&nbsp;ft)$2');
txt.value=txt.value.replace(/([^y]\snine(?:\s|-|&nbsp;)metres?)(\s[^\(\)]{2})/gi, '$1 (29.5&nbsp;ft)$2');
txt.value=txt.value.replace(/([^y]\sten(?:\s|-|&nbsp;)metres?)(\s[^\(\)]{2})/gi, '$1 (32.8&nbsp;ft)$2');
txt.value=txt.value.replace(/([^y]\seleven(?:\s|-|&nbsp;)metres?)(\s[^\(\)]{2})/gi, '$1 (36&nbsp;ft)$2');
txt.value=txt.value.replace(/([^y]\stwelve(?:\s|-|&nbsp;)metres?)(\s[^\(\)]{2})/gi, '$1 (39&nbsp;ft)$2');
txt.value=txt.value.replace(/([^y]\sthirteen(?:\s|-|&nbsp;)metres?)(\s[^\(\)]{2})/gi, '$1 (42.6&nbsp;ft)$2');
txt.value=txt.value.replace(/([^y]\sfourteen(?:\s|-|&nbsp;)metres?)(\s[^\(\)]{2})/gi, '$1 (46&nbsp;ft)$2');
txt.value=txt.value.replace(/([^y]\sfifteen(?:\s|-|&nbsp;)metres?)(\s[^\(\)]{2})/gi, '$1 (49&nbsp;ft)$2');
txt.value=txt.value.replace(/([^y]\ssixteen(?:\s|-|&nbsp;)metres?)(\s[^\(\)]{2})/gi, '$1 (52.5&nbsp;ft)$2');
txt.value=txt.value.replace(/([^y]\sseventeen(?:\s|-|&nbsp;)metres?)(\s[^\(\)]{2})/gi, '$1 (56&nbsp;ft)$2');
txt.value=txt.value.replace(/([^y]\seighteen(?:\s|-|&nbsp;)metres?)(\s[^\(\)]{2})/gi, '$1 (59&nbsp;ft)$2');
txt.value=txt.value.replace(/([^y]\snineteen(?:\s|-|&nbsp;)metres?)(\s[^\(\)]{2})/gi, '$1 (62&nbsp;ft)$2');
txt.value=txt.value.replace(/([^y]\stwenty(?:\s|-|&nbsp;)metres?)(\s[^\(\)]{2})/gi, '$1 (65.6&nbsp;ft)$2');
 
//meters: plural (American spelling)
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(000),?(000)(?:\s|-|&nbsp;)meters([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m|ft|spell=us\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}00),?(000)(?:\s|-|&nbsp;)meters([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m|ft|spell=us\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}0),?(000)(?:\s|-|&nbsp;)meters([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m|ft|spell=us\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)meters([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m|ft|spell=us\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)meters([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m|ft|spell=us\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)meters([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m|ft|spell=us\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)meters([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m|ft|spell=us\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d)(?:\s|-|&nbsp;)meters([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4$5|m|ft|spell=us\}\}$6');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d\d)(?:\s|-|&nbsp;)meters([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4$5|m|ft|spell=us\}\}$6');
 
//meters: singular (American spelling)
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(000),?(000)(?:\s|-|&nbsp;)meter(\s[^\(\/])/gi, '$1\{\{convert|$2$3$4|m|ft|sing=on|spell=us\}\}$5');
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(\d{1,3}00),?(000)(?:\s|-|&nbsp;)meter(\s[^\(\/])/gi, '$1\{\{convert|$2$3$4|m|ft|sing=on|spell=us\}\}$5');
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(\d{1,3}0),?(000)(?:\s|-|&nbsp;)meter(\s[^\(\/])/gi, '$1\{\{convert|$2$3$4|m|ft|sing=on|spell=us\}\}$5');
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)meter(\s[^\(\/])/gi, '$1\{\{convert|$2$3$4|m|ft|sing=on|spell=us\}\}$5');
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)meter(\s[^\(\/])/gi, '$1\{\{convert|$2$3$4|m|ft|sing=on|spell=us\}\}$5');
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)meter(\s[^\(\/])/gi, '$1\{\{convert|$2$3$4|m|ft|sing=on|spell=us\}\}$5');
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)meter(\s[^\(\/])/gi, '$1\{\{convert|$2$3$4|m|ft|sing=on|spell=us\}\}$5');
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)meter(\s[^\(\/])/gi, '$1\{\{convert|$2$3$4|m|ft|sing=on|spell=us\}\}$5');
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d)(?:\s|-|&nbsp;)meter(\s[^\(\/])/gi, '$1\{\{convert|$2$3$4$5|m|ft|sing=on|spell=us\}\}$6');
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d\d)(?:\s|-|&nbsp;)meter(\s[^\(\/])/gi, '$1\{\{convert|$2$3$4$5|m|ft|sing=on|spell=us\}\}$6');

//meters: in full (American spelling)
txt.value=txt.value.replace(/([^y]\sone(?:\s|-|&nbsp;)meter?)(\s[^\(\)]{2})/gi, '$1 (3.2&nbsp;ft)$2');
txt.value=txt.value.replace(/([^y]\stwo(?:\s|-|&nbsp;)meters?)(\s[^\(\)]{2})/gi, '$1 (6.5&nbsp;ft)$2');
txt.value=txt.value.replace(/([^y]\sthree(?:\s|-|&nbsp;)meters?)(\s[^\(\)]{2})/gi, '$1 (10&nbsp;ft)$2');
txt.value=txt.value.replace(/([^y]\sfour(?:\s|-|&nbsp;)meters?)(\s[^\(\)]{2})/gi, '$1 (13&nbsp;ft)$2');
txt.value=txt.value.replace(/([^y]\sfive(?:\s|-|&nbsp;)meters?)(\s[^\(\)]{2})/gi, '$1 (16.4&nbsp;ft)$2');
txt.value=txt.value.replace(/([^y]\ssix(?:\s|-|&nbsp;)meters?)(\s[^\(\)]{2})/gi, '$1 (19.7&nbsp;ft)$2');
txt.value=txt.value.replace(/([^y]\sseven(?:\s|-|&nbsp;)meters?)(\s[^\(\)]{2})/gi, '$1 (23&nbsp;ft)$2');
txt.value=txt.value.replace(/([^y]\seight(?:\s|-|&nbsp;)meters?)(\s[^\(\)]{2})/gi, '$1 (26.2&nbsp;ft)$2');
txt.value=txt.value.replace(/([^y]\snine(?:\s|-|&nbsp;)meters?)(\s[^\(\)]{2})/gi, '$1 (29.5&nbsp;ft)$2');
txt.value=txt.value.replace(/([^y]\sten(?:\s|-|&nbsp;)meters?)(\s[^\(\)]{2})/gi, '$1 (32.8&nbsp;ft)$2');
txt.value=txt.value.replace(/([^y]\seleven(?:\s|-|&nbsp;)meters?)(\s[^\(\)]{2})/gi, '$1 (36&nbsp;ft)$2');
txt.value=txt.value.replace(/([^y]\stwelve(?:\s|-|&nbsp;)meters?)(\s[^\(\)]{2})/gi, '$1 (39&nbsp;ft)$2');
txt.value=txt.value.replace(/([^y]\sthirteen(?:\s|-|&nbsp;)meters?)(\s[^\(\)]{2})/gi, '$1 (42.6&nbsp;ft)$2');
txt.value=txt.value.replace(/([^y]\sfourteen(?:\s|-|&nbsp;)meters?)(\s[^\(\)]{2})/gi, '$1 (46&nbsp;ft)$2');
txt.value=txt.value.replace(/([^y]\sfifteen(?:\s|-|&nbsp;)meters?)(\s[^\(\)]{2})/gi, '$1 (49&nbsp;ft)$2');
txt.value=txt.value.replace(/([^y]\ssixteen(?:\s|-|&nbsp;)meters?)(\s[^\(\)]{2})/gi, '$1 (52.5&nbsp;ft)$2');
txt.value=txt.value.replace(/([^y]\sseventeen(?:\s|-|&nbsp;)meters?)(\s[^\(\)]{2})/gi, '$1 (56&nbsp;ft)$2');
txt.value=txt.value.replace(/([^y]\seighteen(?:\s|-|&nbsp;)meters?)(\s[^\(\)]{2})/gi, '$1 (59&nbsp;ft)$2');
txt.value=txt.value.replace(/([^y]\snineteen(?:\s|-|&nbsp;)meters?)(\s[^\(\)]{2})/gi, '$1 (62&nbsp;ft)$2');
txt.value=txt.value.replace(/([^y]\stwenty(?:\s|-|&nbsp;)meters?)(\s[^\(\)]{2})/gi, '$1 (65.6&nbsp;ft)$2');


//metres per second
//metres per second:plural  (British Imperial spelling)
txt.value=txt.value.replace(/(\s)(\d{1,3}00)?,?(000)(?:\s|-|&nbsp;)metres\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3|m/s|ft/s|\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3}0)?,?(000)(?:\s|-|&nbsp;)metres\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3|m/s|ft/s|\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(000)(?:\s|-|&nbsp;)metres\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3|m/s|ft/s|\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)metres\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3|m/s|ft/s|\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)metres\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3|m/s|ft/s|\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)metres\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3|m/s|ft/s|\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})(\.\d)(?:\s|-|&nbsp;)metres\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m/s|ft/s|\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})(\.\d\d)(?:\s|-|&nbsp;)metres\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m/s|ft/s|\}\}$5');


//metres per second:singular  (British Imperial spelling)
txt.value=txt.value.replace(/(\s)(\d{1,3}00)?,?(000)(?:\s|-|&nbsp;)metre\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3|m/s|ft/s|sing=on\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3}0)?,?(000)(?:\s|-|&nbsp;)metre\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3|m/s|ft/s|sing=on\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(000)(?:\s|-|&nbsp;)metre\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3|m/s|ft/s|sing=on\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)metre\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3|m/s|ft/s|sing=on\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)metre\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3|m/s|ft/s|sing=on\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)metre\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3|m/s|ft/s|sing=on\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})(\.\d)(?:\s|-|&nbsp;)metre\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m/s|ft/s|sing=on\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})(\.\d\d)(?:\s|-|&nbsp;)metre\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m/s|ft/s|sing=on\}\}$5');


//metres per second:abbreviated  (British Imperial spelling)
txt.value=txt.value.replace(/(\s)(\d{1,3}00)?,?(000)(?:\s|-|&nbsp;)m\/s([^\(\)]{2})/gi, '$1\{\{convert|$2$3|m/s|ft/s|abbr=on\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3}0)?,?(000)(?:\s|-|&nbsp;)m\/s([^\(\)]{2})/gi, '$1\{\{convert|$2$3|m/s|ft/s|abbr=on\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(000)(?:\s|-|&nbsp;)m\/s([^\(\)]{2})/gi, '$1\{\{convert|$2$3|m/s|ft/s|abbr=on\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)m\/s([^\(\)]{2})/gi, '$1\{\{convert|$2$3|m/s|ft/s|abbr=on\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)m\/s([^\(\)]{2})/gi, '$1\{\{convert|$2$3|m/s|ft/s|abbr=on\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)m\/s([^\(\)]{2})/gi, '$1\{\{convert|$2$3|m/s|ft/s|abbr=on\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})(\.\d)(?:\s|-|&nbsp;)m\/s([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m/s|ft/s|abbr=on\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})(\.\d\d)(?:\s|-|&nbsp;)m\/s([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m/s|ft/s|abbr=on\}\}$5');

//meters per second:plural  (American spelling)
txt.value=txt.value.replace(/(\s)(\d{1,3}00)?,?(000)(?:\s|-|&nbsp;)meters\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3|m/s|ft/s|spell=us\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3}0)?,?(000)(?:\s|-|&nbsp;)meters\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3|m/s|ft/s|spell=us\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(000)(?:\s|-|&nbsp;)meters\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3|m/s|ft/s|spell=us\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)meters\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3|m/s|ft/s|spell=us\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)meters\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3|m/s|ft/s|spell=us\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)meters\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3|m/s|ft/s|spell=us\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})(\.\d)(?:\s|-|&nbsp;)meters\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m/s|ft/s|spell=us\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})(\.\d\d)(?:\s|-|&nbsp;)meters\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m/s|ft/s|spell=us\}\}$5');


//meters per second:singular  (American spelling)
txt.value=txt.value.replace(/(\s)(\d{1,3}00)?,?(000)(?:\s|-|&nbsp;)meter\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3|m/s|ft/s|sing=on|spell=us\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3}0)?,?(000)(?:\s|-|&nbsp;)meter\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3|m/s|ft/s|sing=on|spell=us\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(000)(?:\s|-|&nbsp;)meter\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3|m/s|ft/s|sing=on|spell=us\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)meter\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3|m/s|ft/s|sing=on|spell=us\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)meter\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3|m/s|ft/s|sing=on|spell=us\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)meter\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3|m/s|ft/s|sing=on|spell=us\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})(\.\d)(?:\s|-|&nbsp;)meter\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m/s|ft/s|sing=on|spell=us\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})(\.\d\d)(?:\s|-|&nbsp;)meter\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m/s|ft/s|sing=on|spell=us\}\}$5');


 
 
    // millimetre
txt.value=txt.value.replace(/(\d)\s?mm(\W)/g, '$1 mm$2');
txt.value=txt.value.replace(/(\d)\-mm(\W)/g, '$1 mm$2');
 
 
    // kilometre
txt.value=txt.value.replace(/\[\[(kilometre|kilometer)\]\]/gi, '$1');
txt.value=txt.value.replace(/(\d)\s?kms?(\W)/gi, '$1 km$2');
txt.value=txt.value.replace(/(\d)\-kms?(\W)/gi, '$1 km$2');
txt.value=txt.value.replace(/(\d)&nbsp;kms?(\W)/gi, '$1&nbsp;km$2');

    //kilometre (British Imperial spelling)
txt.value=txt.value.replace(/\[\[(kilometre)\]\]/gi, '$1');
txt.value=txt.value.replace(/(\d)-(kilometre)/gi, '$1 $2');
//kilometres: plural (British Imperial spelling)
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(000),?(000)(?:\s|-|&nbsp;)kilometres([^p\(\)]{2})/gi, '$1\{\{convert|$2$3$4|km|mi|\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3}00),?(000)(?:\s|-|&nbsp;)kilometres([^p\(\)]{2})/gi, '$1\{\{convert|$2$3$4|km|mi|\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3}0),?(000)(?:\s|-|&nbsp;)kilometres([^p\(\)]{2})/gi, '$1\{\{convert|$2$3$4|km|mi|\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)kilometres([^p\(\)]{2})/gi, '$1\{\{convert|$2$3$4|km|mi|\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)kilometres([^p\(\)]{2})/gi, '$1\{\{convert|$2$3$4|km|mi|\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)kilometres([^p\(\)]{2})/gi, '$1\{\{convert|$2$3$4|km|mi|\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)kilometres([^p\(\)]{2})/gi, '$1\{\{convert|$2$3$4|km|mi|\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d)(?:\s|-|&nbsp;)kilometres([^p\(\)]{2})/gi, '$1\{\{convert|$2$3$4$5|km|mi|\}\}$6');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d\d)(?:\s|-|&nbsp;)kilometres([^p\(\)]{2})/gi, '$1\{\{convert|$2$3$4$5|km|mi|\}\}$6');
//kilometres: singular (British Imperial spelling)
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(000),?(000)(?:\s|-|&nbsp;)kilometre([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4|km|mi|sing=on\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3}00),?(000)(?:\s|-|&nbsp;)kilometre([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4|km|mi|sing=on\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3}0),?(000)(?:\s|-|&nbsp;)kilometre([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4|km|mi|sing=on\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)kilometre([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4|km|mi|sing=on\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)kilometre([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4|km|mi|sing=on\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)kilometre([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4|km|mi|sing=on\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)kilometre([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4|km|mi|sing=on\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)kilometre([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4|km|mi|sing=on\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d)(?:\s|-|&nbsp;)kilometre([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4$5|km|mi|sing=on\}\}$6');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d\d)(?:\s|-|&nbsp;)kilometre([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4$5|km|mi|sing=on\}\}$6');
//kilometres: abbreviated
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(000),?(000)(?:\s|-|&nbsp;)km(\.|\,|\s[^\(\)])/gi, '$1\{\{convert|$2$3$4|km|mi|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3}00),?(000)(?:\s|-|&nbsp;)km(\.|\,|\s[^\(\)])/gi, '$1\{\{convert|$2$3$4|km|mi|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3}0),?(000)(?:\s|-|&nbsp;)km(\.|\,|\s[^\(\)])/gi, '$1\{\{convert|$2$3$4|km|mi|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)km(\.|\,|\s[^\(\)])/gi, '$1\{\{convert|$2$3$4|km|mi|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)km(\.|\,|\s[^\(\)])/gi, '$1\{\{convert|$2$3$4|km|mi|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)km(\.|\,|\s[^\(\)])/gi, '$1\{\{convert|$2$3$4|km|mi|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)km(\.|\,|\s[^\(\)])/gi, '$1\{\{convert|$2$3$4|km|mi|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d)(?:\s|-|&nbsp;)km(\.|\,|\s[^\(\)])/gi, '$1\{\{convert|$2$3$4$5|km|mi|abbr=on\}\}$6');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d\d)(?:\s|-|&nbsp;)km(\.|\,|\s[^\(\)])/gi, '$1\{\{convert|$2$3$4$5|km|mi|abbr=on\}\}$6');

//kilometres: in full (British Imperial spelling)
txt.value=txt.value.replace(/([^y]\sone(?:\s|-|&nbsp;)kilometres?)(\s[^p\(\)]{2})/gi, '$1 (0.6&nbsp;mi)$2');
txt.value=txt.value.replace(/([^y]\stwo(?:\s|-|&nbsp;)kilometres?)(\s[^p\(\)]{2})/gi, '$1 (1.25&nbsp;mi)$2');
txt.value=txt.value.replace(/([^y]\sthree(?:\s|-|&nbsp;)kilometres?)(\s[^p\(\)]{2})/gi, '$1 (2&nbsp;mi)$2');
txt.value=txt.value.replace(/([^y]\sfour(?:\s|-|&nbsp;)kilometres?)(\s[^p\(\)]{2})/gi, '$1 (2.5&nbsp;mi)$2');
txt.value=txt.value.replace(/([^y]\sfive(?:\s|-|&nbsp;)kilometres?)(\s[^p\(\)]{2})/gi, '$1 (3.1&nbsp;mi)$2');
txt.value=txt.value.replace(/([^y]\ssix(?:\s|-|&nbsp;)kilometres?)(\s[^p\(\)]{2})/gi, '$1 (3.75&nbsp;mi)$2');
txt.value=txt.value.replace(/([^y]\sseven(?:\s|-|&nbsp;)kilometres?)(\s[^p\(\)]{2})/gi, '$1 (4.4&nbsp;mi)$2');
txt.value=txt.value.replace(/([^y]\seight(?:\s|-|&nbsp;)kilometres?)(\s[^p\(\)]{2})/gi, '$1 (5&nbsp;mi)$2');
txt.value=txt.value.replace(/([^y]\snine(?:\s|-|&nbsp;)kilometres?)(\s[^p\(\)]{2})/gi, '$1 (5.6&nbsp;mi)$2');
txt.value=txt.value.replace(/([^y]\sten(?:\s|-|&nbsp;)kilometres?)(\s[^p\(\)]{2})/gi, '$1 (6.2&nbsp;mi)$2');
txt.value=txt.value.replace(/([^y]\seleven(?:\s|-|&nbsp;)kilometres?)(\s[^p\(\)]{2})/gi, '$1 (6.8&nbsp;mi)$2');
txt.value=txt.value.replace(/([^y]\stwelve(?:\s|-|&nbsp;)kilometres?)(\s[^p\(\)]{2})/gi, '$1 (7.5&nbsp;mi)$2');
txt.value=txt.value.replace(/([^y]\sthirteen(?:\s|-|&nbsp;)kilometres?)(\s[^p\(\)]{2})/gi, '$1 (8.1&nbsp;mi)$2');
txt.value=txt.value.replace(/([^y]\sfourteen(?:\s|-|&nbsp;)kilometres?)(\s[^p\(\)]{2})/gi, '$1 (8.7&nbsp;mi)$2');
txt.value=txt.value.replace(/([^y]\sfifteen(?:\s|-|&nbsp;)kilometres?)(\s[^p\(\)]{2})/gi, '$1 (9.3&nbsp;mi)$2');
txt.value=txt.value.replace(/([^y]\ssixteen(?:\s|-|&nbsp;)kilometres?)(\s[^p\(\)]{2})/gi, '$1 (10&nbsp;mi)$2');
txt.value=txt.value.replace(/([^y]\sseventeen(?:\s|-|&nbsp;)kilometres?)(\s[^p\(\)]{2})/gi, '$1 (10.6&nbsp;mi)$2');
txt.value=txt.value.replace(/([^y]\seighteen(?:\s|-|&nbsp;)kilometres?)(\s[^p\(\)]{2})/gi, '$1 (11.2&nbsp;mi)$2');
txt.value=txt.value.replace(/([^y]\snineteen(?:\s|-|&nbsp;)kilometres?)(\s[^p\(\)]{2})/gi, '$1 (11.8&nbsp;mi)$2');
txt.value=txt.value.replace(/([^y]\stwenty(?:\s|-|&nbsp;)kilometres?)(\s[^p\(\)]{2})/gi, '$1 (12.4&nbsp;mi)$2');
    //kilometer (American spelling)
txt.value=txt.value.replace(/\[\[(kilometer)\]\]/gi, '$1');
txt.value=txt.value.replace(/(\d)-(kilometer)/gi, '$1 $2');
//kilometers: plural (American spelling)
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(000),?(000)(?:\s|-|&nbsp;)kilometers([^p\(\)]{2})/gi, '$1\{\{convert|$2$3$4|km|mi|spell=us\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3}00),?(000)(?:\s|-|&nbsp;)kilometers([^p\(\)]{2})/gi, '$1\{\{convert|$2$3$4|km|mi|spell=us\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3}0),?(000)(?:\s|-|&nbsp;)kilometers([^p\(\)]{2})/gi, '$1\{\{convert|$2$3$4|km|mi|spell=us\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)kilometers([^p\(\)]{2})/gi, '$1\{\{convert|$2$3$4|km|mi|spell=us\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)kilometers([^p\(\)]{2})/gi, '$1\{\{convert|$2$3$4|km|mi|spell=us\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)kilometers([^p\(\)]{2})/gi, '$1\{\{convert|$2$3$4|km|mi|spell=us\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)kilometers([^p\(\)]{2})/gi, '$1\{\{convert|$2$3$4|km|mi|spell=us\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d)(?:\s|-|&nbsp;)kilometers([^p\(\)]{2})/gi, '$1\{\{convert|$2$3$4$5|km|mi|spell=us\}\}$6');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d\d)(?:\s|-|&nbsp;)kilometers([^p\(\)]{2})/gi, '$1\{\{convert|$2$3$4$5|km|mi|spell=us\}\}$6');

//kilometers: singular (American spelling)
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(000),?(000)(?:\s|-|&nbsp;)kilometer([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4|km|mi|sing=on|spell=us\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3}00),?(000)(?:\s|-|&nbsp;)kilometer([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4|km|mi|sing=on|spell=us\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3}0),?(000)(?:\s|-|&nbsp;)kilometer([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4|km|mi|sing=on|spell=us\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)kilometer([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4|km|mi|sing=on|spell=us\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)kilometer([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4|km|mi|sing=on|spell=us\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)kilometer([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4|km|mi|sing=on|spell=us\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)kilometer([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4|km|mi|sing=on|spell=us\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)kilometer([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4|km|mi|sing=on|spell=us\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d)(?:\s|-|&nbsp;)kilometer([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4$5|km|mi|sing=on|spell=us\}\}$6');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d\d)(?:\s|-|&nbsp;)kilometer([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4$5|km|mi|sing=on|spell=us\}\}$6');

//kilometers: in full (American spelling)
txt.value=txt.value.replace(/([^y]\sone(?:\s|-|&nbsp;)kilometers?)(\s[^p\(\)]{2})/gi, '$1 (0.6&nbsp;mi)$2');
txt.value=txt.value.replace(/([^y]\stwo(?:\s|-|&nbsp;)kilometers?)(\s[^p\(\)]{2})/gi, '$1 (1.25&nbsp;mi)$2');
txt.value=txt.value.replace(/([^y]\sthree(?:\s|-|&nbsp;)kilometers?)(\s[^p\(\)]{2})/gi, '$1 (2&nbsp;mi)$2');
txt.value=txt.value.replace(/([^y]\sfour(?:\s|-|&nbsp;)kilometers?)(\s[^p\(\)]{2})/gi, '$1 (2.5&nbsp;mi)$2');
txt.value=txt.value.replace(/([^y]\sfive(?:\s|-|&nbsp;)kilometers?)(\s[^p\(\)]{2})/gi, '$1 (3.1&nbsp;mi)$2');
txt.value=txt.value.replace(/([^y]\ssix(?:\s|-|&nbsp;)kilometers?)(\s[^p\(\)]{2})/gi, '$1 (3.75&nbsp;mi)$2');
txt.value=txt.value.replace(/([^y]\sseven(?:\s|-|&nbsp;)kilometers?)(\s[^p\(\)]{2})/gi, '$1 (4.4&nbsp;mi)$2');
txt.value=txt.value.replace(/([^y]\seight(?:\s|-|&nbsp;)kilometers?)(\s[^p\(\)]{2})/gi, '$1 (5&nbsp;mi)$2');
txt.value=txt.value.replace(/([^y]\snine(?:\s|-|&nbsp;)kilometers?)(\s[^p\(\)]{2})/gi, '$1 (5.6&nbsp;mi)$2');
txt.value=txt.value.replace(/([^y]\sten(?:\s|-|&nbsp;)kilometers?)(\s[^p\(\)]{2})/gi, '$1 (6.2&nbsp;mi)$2');
txt.value=txt.value.replace(/([^y]\seleven(?:\s|-|&nbsp;)kilometers?)(\s[^p\(\)]{2})/gi, '$1 (6.8&nbsp;mi)$2');
txt.value=txt.value.replace(/([^y]\stwelve(?:\s|-|&nbsp;)kilometers?)(\s[^p\(\)]{2})/gi, '$1 (7.5&nbsp;mi)$2');
txt.value=txt.value.replace(/([^y]\sthirteen(?:\s|-|&nbsp;)kilometers?)(\s[^p\(\)]{2})/gi, '$1 (8.1&nbsp;mi)$2');
txt.value=txt.value.replace(/([^y]\sfourteen(?:\s|-|&nbsp;)kilometers?)(\s[^p\(\)]{2})/gi, '$1 (8.7&nbsp;mi)$2');
txt.value=txt.value.replace(/([^y]\sfifteen(?:\s|-|&nbsp;)kilometers?)(\s[^p\(\)]{2})/gi, '$1 (9.3&nbsp;mi)$2');
txt.value=txt.value.replace(/([^y]\ssixteen(?:\s|-|&nbsp;)kilometers?)(\s[^p\(\)]{2})/gi, '$1 (10&nbsp;mi)$2');
txt.value=txt.value.replace(/([^y]\sseventeen(?:\s|-|&nbsp;)kilometers?)(\s[^p\(\)]{2})/gi, '$1 (10.6&nbsp;mi)$2');
txt.value=txt.value.replace(/([^y]\seighteen(?:\s|-|&nbsp;)kilometers?)(\s[^p\(\)]{2})/gi, '$1 (11.2&nbsp;mi)$2');
txt.value=txt.value.replace(/([^y]\snineteen(?:\s|-|&nbsp;)kilometers?)(\s[^p\(\)]{2})/gi, '$1 (11.8&nbsp;mi)$2');
txt.value=txt.value.replace(/([^y]\stwenty(?:\s|-|&nbsp;)kilometers?)(\s[^p\(\)]{2})/gi, '$1 (12.4&nbsp;mi)$2');

    // centimetre
txt.value=txt.value.replace(/\[\[(centimetre|centimeter)\]\]/gi, '$1');
txt.value=txt.value.replace(/(\d)\s?cms?(\W)/gi, '$1 cm$2');
txt.value=txt.value.replace(/(\d)\-cms?(\W)/gi, '$1 cm$2');
txt.value=txt.value.replace(/(\d)&nbsp;cms?(\W)/gi, '$1&nbsp;cm$2');

    //centimetre (British Imperial spelling)
txt.value=txt.value.replace(/\[\[(centimetre)\]\]/gi, '$1');
txt.value=txt.value.replace(/(\d)-(centimetre)/gi, '$1 $2');

//centimetres: plural (British Imperial spelling)
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(000),?(000)(?:\s|-|&nbsp;)centimetres([^p\(\)]{2})/gi, '$1\{\{convert|$2$3$4|cm|in|\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3}00),?(000)(?:\s|-|&nbsp;)centimetres([^p\(\)]{2})/gi, '$1\{\{convert|$2$3$4|cm|in|\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3}0),?(000)(?:\s|-|&nbsp;)centimetres([^p\(\)]{2})/gi, '$1\{\{convert|$2$3$4|cm|in|\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)centimetres([^p\(\)]{2})/gi, '$1\{\{convert|$2$3$4|cm|in|\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)centimetres([^p\(\)]{2})/gi, '$1\{\{convert|$2$3$4|cm|in|\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)centimetres([^p\(\)]{2})/gi, '$1\{\{convert|$2$3$4|cm|in|\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)centimetres([^p\(\)]{2})/gi, '$1\{\{convert|$2$3$4|cm|in|\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d)(?:\s|-|&nbsp;)centimetres([^p\(\)]{2})/gi, '$1\{\{convert|$2$3$4$5|cm|in|\}\}$6');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d\d)(?:\s|-|&nbsp;)centimetres([^p\(\)]{2})/gi, '$1\{\{convert|$2$3$4$5|cm|in|\}\}$6');
//centimetres: singular (British Imperial spelling)
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(000),?(000)(?:\s|-|&nbsp;)centimetre([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4|cm|in|sing=on\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3}00),?(000)(?:\s|-|&nbsp;)centimetre([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4|cm|in|sing=on\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3}0),?(000)(?:\s|-|&nbsp;)centimetre([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4|cm|in|sing=on\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)centimetre([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4|cm|in|sing=on\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)centimetre([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4|cm|in|sing=on\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)centimetre([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4|cm|in|sing=on\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)centimetre([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4|cm|in|sing=on\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)centimetre([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4|cm|in|sing=on\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d)(?:\s|-|&nbsp;)centimetre([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4$5|cm|in|sing=on\}\}$6');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d\d)(?:\s|-|&nbsp;)centimetre([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4$5|cm|in|sing=on\}\}$6');
//centimetres: abbreviated
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(000),?(000)(?:\s|-|&nbsp;)cm(\.|\,|\s[^\(\)])/gi, '$1\{\{convert|$2$3$4|cm|in|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3}00),?(000)(?:\s|-|&nbsp;)cm(\.|\,|\s[^\(\)])/gi, '$1\{\{convert|$2$3$4|cm|in|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3}0),?(000)(?:\s|-|&nbsp;)cm(\.|\,|\s[^\(\)])/gi, '$1\{\{convert|$2$3$4|cm|in|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)cm(\.|\,|\s[^\(\)])/gi, '$1\{\{convert|$2$3$4|cm|in|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)cm(\.|\,|\s[^\(\)])/gi, '$1\{\{convert|$2$3$4|cm|in|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)cm(\.|\,|\s[^\(\)])/gi, '$1\{\{convert|$2$3$4|cm|in|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)cm(\.|\,|\s[^\(\)])/gi, '$1\{\{convert|$2$3$4|cm|in|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d)(?:\s|-|&nbsp;)cm(\.|\,|\s[^\(\)])/gi, '$1\{\{convert|$2$3$4$5|cm|in|abbr=on\}\}$6');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d\d)(?:\s|-|&nbsp;)cm(\.|\,|\s[^\(\)])/gi, '$1\{\{convert|$2$3$4$5|cm|in|abbr=on\}\}$6');

//centimetres: in full (British Imperial spelling)
txt.value=txt.value.replace(/([^y]\sone(?:\s|-|&nbsp;)centimetres?)(\s[^p\(\)]{2})/gi, '$1 (0.4&nbsp;in)$2');
txt.value=txt.value.replace(/([^y]\stwo(?:\s|-|&nbsp;)centimetres?)(\s[^p\(\)]{2})/gi, '$1 (0.8&nbsp;in)$2');
txt.value=txt.value.replace(/([^y]\sthree(?:\s|-|&nbsp;)centimetres?)(\s[^p\(\)]{2})/gi, '$1 (1.2&nbsp;in)$2');
txt.value=txt.value.replace(/([^y]\sfour(?:\s|-|&nbsp;)centimetres?)(\s[^p\(\)]{2})/gi, '$1 (1.6&nbsp;in)$2');
txt.value=txt.value.replace(/([^y]\sfive(?:\s|-|&nbsp;)centimetres?)(\s[^p\(\)]{2})/gi, '$1 (2.0&nbsp;in)$2');
txt.value=txt.value.replace(/([^y]\ssix(?:\s|-|&nbsp;)centimetres?)(\s[^p\(\)]{2})/gi, '$1 (2.4&nbsp;in)$2');
txt.value=txt.value.replace(/([^y]\sseven(?:\s|-|&nbsp;)centimetres?)(\s[^p\(\)]{2})/gi, '$1 (2.75&nbsp;in)$2');
txt.value=txt.value.replace(/([^y]\seight(?:\s|-|&nbsp;)centimetres?)(\s[^p\(\)]{2})/gi, '$1 (3.2&nbsp;in)$2');
txt.value=txt.value.replace(/([^y]\snine(?:\s|-|&nbsp;)centimetres?)(\s[^p\(\)]{2})/gi, '$1 (3.5&nbsp;in)$2');
txt.value=txt.value.replace(/([^y]\sten(?:\s|-|&nbsp;)centimetres?)(\s[^p\(\)]{2})/gi, '$1 (4&nbsp;in)$2');
txt.value=txt.value.replace(/([^y]\seleven(?:\s|-|&nbsp;)centimetres?)(\s[^p\(\)]{2})/gi, '$1 (4.3&nbsp;in)$2');
txt.value=txt.value.replace(/([^y]\stwelve(?:\s|-|&nbsp;)centimetres?)(\s[^p\(\)]{2})/gi, '$1 (4.7&nbsp;in)$2');
txt.value=txt.value.replace(/([^y]\sthirteen(?:\s|-|&nbsp;)centimetres?)(\s[^p\(\)]{2})/gi, '$1 (5.1&nbsp;in)$2');
txt.value=txt.value.replace(/([^y]\sfourteen(?:\s|-|&nbsp;)centimetres?)(\s[^p\(\)]{2})/gi, '$1 (5.5&nbsp;in)$2');
txt.value=txt.value.replace(/([^y]\sfifteen(?:\s|-|&nbsp;)centimetres?)(\s[^p\(\)]{2})/gi, '$1 (5.9&nbsp;in)$2');
txt.value=txt.value.replace(/([^y]\ssixteen(?:\s|-|&nbsp;)centimetres?)(\s[^p\(\)]{2})/gi, '$1 (6.3&nbsp;in)$2');
txt.value=txt.value.replace(/([^y]\sseventeen(?:\s|-|&nbsp;)centimetres?)(\s[^p\(\)]{2})/gi, '$1 (6.7&nbsp;in)$2');
txt.value=txt.value.replace(/([^y]\seighteen(?:\s|-|&nbsp;)centimetres?)(\s[^p\(\)]{2})/gi, '$1 (7.1&nbsp;in)$2');
txt.value=txt.value.replace(/([^y]\snineteen(?:\s|-|&nbsp;)centimetres?)(\s[^p\(\)]{2})/gi, '$1 (7.5&nbsp;in)$2');
txt.value=txt.value.replace(/([^y]\stwenty(?:\s|-|&nbsp;)centimetres?)(\s[^p\(\)]{2})/gi, '$1 (7.9&nbsp;in)$2');
    //centimeter (American spelling)
txt.value=txt.value.replace(/\[\[(centimeter)\]\]/gi, '$1');
txt.value=txt.value.replace(/(\d)-(centimeter)/gi, '$1 $2');
//centimeters: plural (American spelling)
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(000),?(000)(?:\s|-|&nbsp;)centimeters([^p\(\)]{2})/gi, '$1\{\{convert|$2$3$4|cm|in|spell=us\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3}00),?(000)(?:\s|-|&nbsp;)centimeters([^p\(\)]{2})/gi, '$1\{\{convert|$2$3$4|cm|in|spell=us\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3}0),?(000)(?:\s|-|&nbsp;)centimeters([^p\(\)]{2})/gi, '$1\{\{convert|$2$3$4|cm|in|spell=us\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)centimeters([^p\(\)]{2})/gi, '$1\{\{convert|$2$3$4|cm|in|spell=us\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)centimeters([^p\(\)]{2})/gi, '$1\{\{convert|$2$3$4|cm|in|spell=us\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)centimeters([^p\(\)]{2})/gi, '$1\{\{convert|$2$3$4|cm|in|spell=us\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)centimeters([^p\(\)]{2})/gi, '$1\{\{convert|$2$3$4|cm|in|spell=us\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d)(?:\s|-|&nbsp;)centimeters([^p\(\)]{2})/gi, '$1\{\{convert|$2$3$4$5|cm|in|spell=us\}\}$6');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d\d)(?:\s|-|&nbsp;)centimeters([^p\(\)]{2})/gi, '$1\{\{convert|$2$3$4$5|cm|in|spell=us\}\}$6');

//centimeters: singular (American spelling)
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(000),?(000)(?:\s|-|&nbsp;)centimeter([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4|cm|in|sing=on|spell=us\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3}00),?(000)(?:\s|-|&nbsp;)centimeter([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4|cm|in|sing=on|spell=us\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3}0),?(000)(?:\s|-|&nbsp;)centimeter([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4|cm|in|sing=on|spell=us\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)centimeter([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4|cm|in|sing=on|spell=us\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)centimeter([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4|cm|in|sing=on|spell=us\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)centimeter([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4|cm|in|sing=on|spell=us\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)centimeter([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4|cm|in|sing=on|spell=us\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)centimeter([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4|cm|in|sing=on|spell=us\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d)(?:\s|-|&nbsp;)centimeter([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4$5|cm|in|sing=on|spell=us\}\}$6');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d\d)(?:\s|-|&nbsp;)centimeter([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4$5|cm|in|sing=on|spell=us\}\}$6');

//centimeters: in full (American spelling)
txt.value=txt.value.replace(/([^y]\sone(?:\s|-|&nbsp;)centimeters?)(\s[^p\(\)]{2})/gi, '$1 (0.4&nbsp;in)$2');
txt.value=txt.value.replace(/([^y]\stwo(?:\s|-|&nbsp;)centimeters?)(\s[^p\(\)]{2})/gi, '$1 (0.8&nbsp;in)$2');
txt.value=txt.value.replace(/([^y]\sthree(?:\s|-|&nbsp;)centimeters?)(\s[^p\(\)]{2})/gi, '$1 (1.2&nbsp;in)$2');
txt.value=txt.value.replace(/([^y]\sfour(?:\s|-|&nbsp;)centimeters?)(\s[^p\(\)]{2})/gi, '$1 (1.6&nbsp;in)$2');
txt.value=txt.value.replace(/([^y]\sfive(?:\s|-|&nbsp;)centimeters?)(\s[^p\(\)]{2})/gi, '$1 (2.0&nbsp;in)$2');
txt.value=txt.value.replace(/([^y]\ssix(?:\s|-|&nbsp;)centimeters?)(\s[^p\(\)]{2})/gi, '$1 (2.4&nbsp;in)$2');
txt.value=txt.value.replace(/([^y]\sseven(?:\s|-|&nbsp;)centimeters?)(\s[^p\(\)]{2})/gi, '$1 (2.75&nbsp;in)$2');
txt.value=txt.value.replace(/([^y]\seight(?:\s|-|&nbsp;)centimeters?)(\s[^p\(\)]{2})/gi, '$1 (3.2&nbsp;in)$2');
txt.value=txt.value.replace(/([^y]\snine(?:\s|-|&nbsp;)centimeters?)(\s[^p\(\)]{2})/gi, '$1 (3.5&nbsp;in)$2');
txt.value=txt.value.replace(/([^y]\sten(?:\s|-|&nbsp;)centimeters?)(\s[^p\(\)]{2})/gi, '$1 (4&nbsp;in)$2');
txt.value=txt.value.replace(/([^y]\seleven(?:\s|-|&nbsp;)centimeters?)(\s[^p\(\)]{2})/gi, '$1 (4.3&nbsp;in)$2');
txt.value=txt.value.replace(/([^y]\stwelve(?:\s|-|&nbsp;)centimeters?)(\s[^p\(\)]{2})/gi, '$1 (4.7&nbsp;in)$2');
txt.value=txt.value.replace(/([^y]\sthirteen(?:\s|-|&nbsp;)centimeters?)(\s[^p\(\)]{2})/gi, '$1 (5.1&nbsp;in)$2');
txt.value=txt.value.replace(/([^y]\sfourteen(?:\s|-|&nbsp;)centimeters?)(\s[^p\(\)]{2})/gi, '$1 (5.5&nbsp;in)$2');
txt.value=txt.value.replace(/([^y]\sfifteen(?:\s|-|&nbsp;)centimeters?)(\s[^p\(\)]{2})/gi, '$1 (5.9&nbsp;in)$2');
txt.value=txt.value.replace(/([^y]\ssixteen(?:\s|-|&nbsp;)centimeters?)(\s[^p\(\)]{2})/gi, '$1 (6.3&nbsp;in)$2');
txt.value=txt.value.replace(/([^y]\sseventeen(?:\s|-|&nbsp;)centimeters?)(\s[^p\(\)]{2})/gi, '$1 (6.7&nbsp;in)$2');
txt.value=txt.value.replace(/([^y]\seighteen(?:\s|-|&nbsp;)centimeters?)(\s[^p\(\)]{2})/gi, '$1 (7.1&nbsp;in)$2');
txt.value=txt.value.replace(/([^y]\snineteen(?:\s|-|&nbsp;)centimeters?)(\s[^p\(\)]{2})/gi, '$1 (7.5&nbsp;in)$2');
txt.value=txt.value.replace(/([^y]\stwenty(?:\s|-|&nbsp;)centimeters?)(\s[^p\(\)]{2})/gi, '$1 (7.9&nbsp;in)$2');

  
    //square kilometre
txt.value=txt.value.replace(/\[\[(square\skilometre)\]\]/gi, '$1');
txt.value=txt.value.replace(/(\d)\s?sq\.?\s?kms?/gi, '$1 km²');
txt.value=txt.value.replace(/([^\|])sq\.?\s?kms?/gi, '$1km²');
txt.value=txt.value.replace(/sq&nbsp;kms?/gi, 'km²');

// square kilometre:plural (British Imperial spelling)
txt.value=txt.value.replace(/(\s)(\d{1,3}),?(000),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)kilometres([^²\(]{4})/gi, '$1\{\{convert|$2$3$4|km2|sqmi|\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}00),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)kilometres([^²\(]{2})/gi, '$1\{\{convert|$2$3$4|km2|sqmi|\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}0),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)kilometres([^²\(]{2})/gi, '$1\{\{convert|$2$3$4|km2|sqmi|\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)kilometres([^²\(]{2})/gi, '$1\{\{convert|$2$3$4|km2|sqmi|\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)kilometres([^²\(]{2})/gi, '$1\{\{convert|$2$3$4|km2|sqmi|\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)kilometres([^²\(]{2})/gi, '$1\{\{convert|$2$3$4|km2|sqmi|\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)kilometres([^²\(]{2})/gi, '$1\{\{convert|$2$3$4|km2|sqmi|\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)kilometres([^²\(]{2})/gi, '$1\{\{convert|$2$3$4$5|km2|sqmi|\}\}$6');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d\d)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)kilometres([^²\(]{2})/gi, '$1\{\{convert|$2$3$4$5|km2|sqmi|\}\}$6');

// square kilometre:singular (British Imperial spelling)
txt.value=txt.value.replace(/(\s)(\d{1,3}),?(000),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)kilometres?([^s²\(]{2})/gi, '$1\{\{convert|$2$3$4|km2|sqmi|\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}00),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)kilometres?([^s²\(]{2})/gi, '$1\{\{convert|$2$3$4|km2|sqmi|\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}0),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)kilometres?([^s²\(]{2})/gi, '$1\{\{convert|$2$3$4|km2|sqmi|\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)kilometres?([^s²\(]{2})/gi, '$1\{\{convert|$2$3$4|km2|sqmi|\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)kilometres?([^s²\(]{2})/gi, '$1\{\{convert|$2$3$4|km2|sqmi|\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)kilometres?([^s²\(]{2})/gi, '$1\{\{convert|$2$3$4|km2|sqmi|\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)kilometres?([^s²\(]{2})/gi, '$1\{\{convert|$2$3$4|km2|sqmi|\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)kilometres?([^s²\(]{2})/gi, '$1\{\{convert|$2$3$4$5|km2|sqmi|\}\}$6');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d\d)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)kilometres?([^s²\(]{2})/gi, '$1\{\{convert|$2$3$4$5|km2|sqmi|\}\}$6');

 
// square kilometer:plural (American spelling)
txt.value=txt.value.replace(/(\s)(\d{1,3}),?(000),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)kilometers([^²\(]{4})/gi, '$1\{\{convert|$2$3$4|km2|sqmi|spell=us\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}00),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)kilometers([^²\(]{2})/gi, '$1\{\{convert|$2$3$4|km2|sqmi|spell=us\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}0),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)kilometers([^²\(]{2})/gi, '$1\{\{convert|$2$3$4|km2|sqmi|spell=us\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)kilometers([^²\(]{2})/gi, '$1\{\{convert|$2$3$4|km2|sqmi|spell=us\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)kilometers([^²\(]{2})/gi, '$1\{\{convert|$2$3$4|km2|sqmi|spell=us\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)kilometers([^²\(]{2})/gi, '$1\{\{convert|$2$3$4|km2|sqmi|spell=us\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)kilometers([^²\(]{2})/gi, '$1\{\{convert|$2$3$4|km2|sqmi|spell=us\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)kilometers([^²\(]{2})/gi, '$1\{\{convert|$2$3$4$5|km2|sqmi|spell=us\}\}$6');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d\d)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)kilometers([^²\(]{2})/gi, '$1\{\{convert|$2$3$4$5|km2|sqmi|spell=us\}\}$6');

// square kilometer:singular (American spelling)
txt.value=txt.value.replace(/(\s)(\d{1,3}),?(000),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)kilometers?([^s²\(]{2})/gi, '$1\{\{convert|$2$3$4|km2|sqmi|spell=us\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}00),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)kilometers?([^s²\(]{2})/gi, '$1\{\{convert|$2$3$4|km2|sqmi|spell=us\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}0),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)kilometers?([^s²\(]{2})/gi, '$1\{\{convert|$2$3$4|km2|sqmi|spell=us\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)kilometers?([^s²\(]{2})/gi, '$1\{\{convert|$2$3$4|km2|sqmi|spell=us\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)kilometers?([^s²\(]{2})/gi, '$1\{\{convert|$2$3$4|km2|sqmi|spell=us\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)kilometers?([^s²\(]{2})/gi, '$1\{\{convert|$2$3$4|km2|sqmi|spell=us\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)kilometers?([^s²\(]{2})/gi, '$1\{\{convert|$2$3$4|km2|sqmi|spell=us\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)kilometers?([^s²\(]{2})/gi, '$1\{\{convert|$2$3$4$5|km2|sqmi|spell=us\}\}$6');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d\d)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)kilometers?([^s²\(]{2})/gi, '$1\{\{convert|$2$3$4$5|km2|sqmi|spell=us\}\}$6');


// square kilometre:abbreviated sq km
txt.value=txt.value.replace(/(\s)(\d{1,3}),?(000),?(000)(?:\s|-|&nbsp;)sq(?:\s|-|&nbsp;)km([^l²\(]{2})/gi, '$1\{\{convert|$2$3$4|km2|sqmi|abbr=on\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}00),?(000)(?:\s|-|&nbsp;)sq(?:\s|-|&nbsp;)km([^l²\(]{2})/gi, '$1\{\{convert|$2$3$4|km2|sqmi|abbr=on\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}0),?(000)(?:\s|-|&nbsp;)sq(?:\s|-|&nbsp;)km([^l²\(]{2})/gi, '$1\{\{convert|$2$3$4|km2|sqmi|abbr=on\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)sq(?:\s|-|&nbsp;)km([^l²\(]{2})/gi, '$1\{\{convert|$2$3$4|km2|sqmi|abbr=on\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)sq(?:\s|-|&nbsp;)km([^l²\(]{2})/gi, '$1\{\{convert|$2$3$4|km2|sqmi|abbr=on\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)sq(?:\s|-|&nbsp;)km([^l²\(]{2})/gi, '$1\{\{convert|$2$3$4|km2|sqmi|abbr=on\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)sq(?:\s|-|&nbsp;)km([^l²\(]{2})/gi, '$1\{\{convert|$2$3$4|km2|sqmi|abbr=on\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d)(?:\s|-|&nbsp;)sq(?:\s|-|&nbsp;)km([^l²\(]{2})/gi, '$1\{\{convert|$2$3$4$5|km2|sqmi|abbr=on\}\}$6');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d\d)(?:\s|-|&nbsp;)sq(?:\s|-|&nbsp;)km([^l²\(]{2})/gi, '$1\{\{convert|$2$3$4$5|km2|sqmi|abbr=on\}\}$6');

// square kilometre:abbreviated km²
txt.value=txt.value.replace(/(\s)(\d{1,3}),?(000),?(000)(?:\s|-|&nbsp;)km²(\.|\,|\s[^l²\(]{2})/gi, '$1\{\{convert|$2$3$4|km2|sqmi|abbr=on\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}00),?(000)(?:\s|-|&nbsp;)km²(\.|\,|\s[^l²\(]{2})/gi, '$1\{\{convert|$2$3$4|km2|sqmi|abbr=on\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}0),?(000)(?:\s|-|&nbsp;)km²(\.|\,|\s[^l²\(]{2})/gi, '$1\{\{convert|$2$3$4|km2|sqmi|abbr=on\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)km²(\.|\,|\s[^l²\(]{2})/gi, '$1\{\{convert|$2$3$4|km2|sqmi|abbr=on\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)km²(\.|\,|\s[^l²\(]{2})/gi, '$1\{\{convert|$2$3$4|km2|sqmi|abbr=on\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)km²(\.|\,|\s[^l²\(]{2})/gi, '$1\{\{convert|$2$3$4|km2|sqmi|abbr=on\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)km²(\.|\,|\s[^l²\(]{2})/gi, '$1\{\{convert|$2$3$4|km2|sqmi|abbr=on\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d)(?:\s|-|&nbsp;)km²(\.|\,|\s[^l²\(]{2})/gi, '$1\{\{convert|$2$3$4$5|km2|sqmi|abbr=on\}\}$6');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d\d)(?:\s|-|&nbsp;)km²(\.|\,|\s[^l²\(]{2})/gi, '$1\{\{convert|$2$3$4$5|km2|sqmi|abbr=on\}\}$6');

    // kilometre per hour
txt.value=txt.value.replace(/km\/hr(\W)/gi, 'km/h$1');
txt.value=txt.value.replace(/kph(\W)/gi, 'km/h$1');
txt.value=txt.value.replace(/kmph(\W)/gi, 'km/h$1');
txt.value=txt.value.replace(/(\d)\s?kmh/gi, '$1 km/h');
txt.value=txt.value.replace(/(\d)&nbsp;kmh/gi, '$1&nbsp;km/h');
txt.value=txt.value.replace(/\[\[kmh\]\]/gi, '\[\[km/h\]\]');
txt.value=txt.value.replace(/km\/h/gi, 'km/h');
txt.value=txt.value.replace(/(\d)\s?km\/h/gi, '$1 km/h');
txt.value=txt.value.replace(/(\d)\-km\/h/gi, '$1 km/h');
txt.value=txt.value.replace(/(\d)&nbsp;km\/h/gi, '$1&nbsp;km/h');

txt.value=txt.value.replace(/([^\d]\s)(\d{1,3}00),?(000)(?:\s|-|&nbsp;)km\/h([^\(\)]{3})/gi, '$1\{\{convert|$2$3|km/h|mph|abbr=on\}\}$4');
txt.value=txt.value.replace(/([^\d]\s)(\d{1,3}0),?(000)(?:\s|-|&nbsp;)km\/h([^\(\)]{3})/gi, '$1\{\{convert|$2$3|km/h|mph|abbr=on\}\}$4');
txt.value=txt.value.replace(/([^\d]\s)(\d{1,3}),?(000)(?:\s|-|&nbsp;)km\/h([^\(\)]{3})/gi, '$1\{\{convert|$2$3|km/h|mph|abbr=on\}\}$4');
txt.value=txt.value.replace(/([^\d]\s)(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)km\/h([^\(\)]{3})/gi, '$1\{\{convert|$2$3|km/h|mph|abbr=on\}\}$4');
txt.value=txt.value.replace(/([^\d]\s)(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)km\/h([^\(\)]{3})/gi, '$1\{\{convert|$2$3|km/h|mph|abbr=on\}\}$4');
txt.value=txt.value.replace(/([^\d]\s)(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)km\/h([^\(\)]{3})/gi, '$1\{\{convert|$2$3|km/h|mph|abbr=on\}\}$4');
txt.value=txt.value.replace(/([^\d]\s)(\d{1,3}\.\d\d)(?:\s|-|&nbsp;)km\/h([^\(\)]{3})/gi, '$1\{\{convert|$2|km/h|mph|abbr=on\}\}$3');
txt.value=txt.value.replace(/([^\d]\s)(\d{1,3}\.\d\d\d)(?:\s|-|&nbsp;)km\/h([^\(\)]{3})/gi, '$1\{\{convert|$2|km/h|mph|abbr=on\}\}$3');


    // cubic centimetre
txt.value=txt.value.replace(/(\d)\s?cm(\s)/gi, '$1 cm$2');
txt.value=txt.value.replace(/(\d)\s?cc(\s)/g, '$1 cc$2');
txt.value=txt.value.replace(/(\d)\-cc(\s)/g, '$1 cc$2');
 
    // millilitre
txt.value=txt.value.replace(/(\d)\s?ml(\W)/g, '$1 mL$2');
txt.value=txt.value.replace(/(\d)\-ml(\W)/g, '$1 mL$2');
 
    // second
txt.value=txt.value.replace(/\[\[(s)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[(seconds?)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[seconds?\|([^\]]{1,30})\]\]/gi, '$1');
    //txt.value=txt.value.replace(/\/sec(\W)/gi, '/s$1');
    //txt.value=txt.value.replace(/\/sec\)/gi, '/s)$1');
 
txt.value=txt.value.replace(/(\d)\s?ft\/second/gi, '$1 ft/s');
txt.value=txt.value.replace(/(\d)\s?ft\/sec(\W)/gi, '$1 ft/s$2');
txt.value=txt.value.replace(/(\d)&nbsp;ft\/sec(\W)/gi, '$1&nbsp;ft/s$2');
txt.value=txt.value.replace(/(\d)\s?m\/second/gi, '$1 m/s');
txt.value=txt.value.replace(/(\d)\s?m\/sec(\W)/gi, '$1 m/s$2');
txt.value=txt.value.replace(/(\d)\&nbsp;m\/sec(\W)/gi, '$1&nbsp;m/s$2');
txt.value=txt.value.replace(/(\d)\s?km\/sec(\W)/gi, '$1 km/s$2');
txt.value=txt.value.replace(/frames\/s(\W)/gi, 'frame/s$1');
 
    //minute
txt.value=txt.value.replace(/\[\[(min)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[(minutes?)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[minutes?\|([^\]]{1,30})\]\]/gi, '$1');
 
    // hour
txt.value=txt.value.replace(/\[\[(h)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[(hours?)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[hours?\|([^\]]{1,30})\]\]/gi, '$1');
 
    //day
txt.value=txt.value.replace(/\[\[(d)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[(days?)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[days?\|([^\]]{1,30})\]\]/gi, '$1');
 
    // kilogram
txt.value=txt.value.replace(/(\s)(\d{1,3}00)(?:\s|-|&nbsp;)kilogrammes([^\(\)]{2})/gi, '$1\{\{convert|$2|kg|lb\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3}0)(?:\s|-|&nbsp;)kilogrammes([^\(\)]{2})/gi, '$1\{\{convert|$2\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3})(?:\s|-|&nbsp;)kilogrammes([^\(\)]{2})/gi, '$1\{\{convert|$2\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3}\.\d)(?:\s|-|&nbsp;)kilogrammes([^\(\)]{2})/gi, '$1\{\{convert|$2\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3}\.\d\d)(?:\s|-|&nbsp;)kilogrammes([^\(\)]{2})/gi, '$1\{\{convert||$2\}\}$3');
txt.value=txt.value.replace(/kilogramme/gi, 'kilogram');
txt.value=txt.value.replace(/(\s)(\d{1,3}00)(?:\s|-|&nbsp;)kilogramme([^\(\)]{2})/gi, '$1\{\{convert|$2|kg|lb|abbr=on\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3}0)(?:\s|-|&nbsp;)kilogramme([^\(\)]{2})/gi, '$1\{\{convert|$2|kg|lb|abbr=on\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3})(?:\s|-|&nbsp;)kilogramme([^\(\)]{2})/gi, '$1\{\{convert|$2|kg|lb|abbr=on\}\} $3');
txt.value=txt.value.replace(/(\s)(\d{1,3}\.\d)(?:\s|-|&nbsp;)kilogramme([^\(\)]{2})/gi, '$1\{\{convert|$2|kg|lb|abbr=on\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3}\.\d\d)(?:\s|-|&nbsp;)kilogramme([^\(\)]{2})/gi, '$1\{\{convert|$2|kg|lb|abbr=on\}\}$3');

txt.value=txt.value.replace(/(\s)(\d{1,3}00)(?:\s|-|&nbsp;)s?kg([^\(\)\/]{2})/gi, '$1\{\{convert|$2|kg|lb|abbr=on\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3}0)(?:\s|-|&nbsp;)s?kg([^\(\)\/]{2})/gi, '$1\{\{convert|$2|kg|lb|abbr=on\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3})(?:\s|-|&nbsp;)s?kg([^\(\)\/]{2})/gi, '$1\{\{convert|$2|kg|lb|abbr=on\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3}\.\d)(?:\s|-|&nbsp;)s?kg([^\(\)\/]{2})/gi, '$1\{\{convert|$2|kg|lb|abbr=on\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3}\.\d\d)(?:\s|-|&nbsp;)s?kg([^\(\)\/]{2})/gi, '$1\{\{convert|$2|kg|lb|abbr=on\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3}00)(?:\s|-|&nbsp;)-kg([^\(\)\/]{2})/gi, '$1\{\{convert|$2|kg|lb|abbr=on\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3}0)(?:\s|-|&nbsp;)-kg([^\(\)\/]{2})/gi, '$1\{\{convert|$2|kg|lb|abbr=on\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3})(?:\s|-|&nbsp;)-kg([^\(\)\/]{2})/gi, '$1\{\{convert|$2|kg|lb|abbr=on\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3}\.\d)(?:\s|-|&nbsp;)-kg([^\(\)\/]{2})/gi, '$1\{\{convert|$2|kg|lb|abbr=on\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3}\.\d\d)(?:\s|-|&nbsp;)-kg([^\(\)\/]{2})/gi, '$1\{\{convert|$2|kg|lb|abbr=on\}\}$3');
txt.value=txt.value.replace(/\[\[(kilograms?)\]\]/gi, '$1');

  //grams to ounces
txt.value=txt.value.replace(/(\W)grammes(\W)/gi, '$1grams$2');
txt.value=txt.value.replace(/(\s)(\d{1,3}00)(?:\s|-|&nbsp;)grammes([^\(\)]{2})/gi, '$1\{\{convert|$2|g|oz|\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3}0)(?:\s|-|&nbsp;)grammes([^\(\)]{2})/gi, '$1\{\{convert|$2|g|oz|\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3})(?:\s|-|&nbsp;)grammes([^\(\)]{2})/gi, '$1\{\{convert|$2|g|oz|\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3}\.\d)(?:\s|-|&nbsp;)grammes([^\(\)]{2})/gi, '$1\{\{convert|$2|g|oz|\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3}\.\d\d)(?:\s|-|&nbsp;)grammes([^\(\)]{2})/gi, '$1\{\{convert|$2|g|oz|\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3}00)(?:\s|-|&nbsp;)grams([^\(\)]{2})/gi, '$1\{\{convert|$2|g|oz|\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3}0)(?:\s|-|&nbsp;)grams([^\(\)]{2})/gi, '$1\{\{convert|$2|g|oz|\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3})(?:\s|-|&nbsp;)grams([^\(\)]{2})/gi, '$1\{\{convert|$2|g|oz|\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3}\.\d)(?:\s|-|&nbsp;)grams([^\(\)]{2})/gi, '$1\{\{convert|$2|g|oz|\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3}\.\d\d)(?:\s|-|&nbsp;)grams([^\(\)]{2})/gi, '$1\{\{convert|$2|g|oz|\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3}00)(?:\s|-|&nbsp;)gram([^\(\)]{2})/gi, '$1\{\{Convert|$2|g|oz|sing=on\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3}0)(?:\s|-|&nbsp;)gram([^\(\)]{2})/gi, '$1\{\{Convert|$2|g|oz|sing=on\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3})(?:\s|-|&nbsp;)gram([^\(\)]{2})/gi, '$1\{\{Convert|$2|g|oz|sing=on\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3}\.\d)(?:\s|-|&nbsp;)gram([^\(\)]{2})/gi, '$1\{\{Convert|$2|g|oz|sing=on\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3}\.\d\d)(?:\s|-|&nbsp;)gram([^\(\)]{2})/gi, '$1\{\{convert|$2|g|oz|abbr=on\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3}00)(?:\s|-|&nbsp;)g(\W\s[^\(\)]{2})/gi, '$1\{\{convert|$2|g|oz|abbr=on\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3}0)(?:\s|-|&nbsp;)g(\W\s[^\(\)]{2})/gi, '$1\{\{convert|$2|g|oz|abbr=on\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3})(?:\s|-|&nbsp;)g(\W\s[^\(\)]{2})/gi, '$1\{\{convert|$2|g|oz|abbr=on\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3}\.\d)(?:\s|-|&nbsp;)g(\W\s[^\(\)]{2})/gi, '$1\{\{convert|$2|g|oz|abbr=on\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3}\.\d\d)(?:\s|-|&nbsp;)g(\W\s[^\(\)]{2})/gi, '$1\{\{convert|$2|g|oz|abbr=on\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3}00)(?:\s|-|&nbsp;)gramme([^\(\)]{2})/gi, '$1\{\{convert|$2|g|oz|abbr=on\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3}0)(?:\s|-|&nbsp;)gramme([^\(\)]{2})/gi, '$1\{\{convert|$2|g|oz|abbr=on\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3})(?:\s|-|&nbsp;)gramme([^\(\)]{2})/gi, '$1\{\{convert|$2|g|oz|abbr=on\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3}\.\d)(?:\s|-|&nbsp;)gramme([^\(\)]{2})/gi, '$1\{\{convert|$2|g|oz|abbr=on\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3}\.\d\d)(?:\s|-|&nbsp;)gramme([^\(\)]{2})/gi, '$1\{\{convert|$2|g|oz|abbr=on\}\}$3');
txt.value=txt.value.replace(/(\W)gramme(\W)/gi, '$1gram$2');
  
    // newton metre
txt.value=txt.value.replace(/(\d)\s?(Nm\W)/gi, '$1 $2');
txt.value=txt.value.replace(/(\d)\-(Nm\W)/gi, '$1 $2');
 
    // kilowatt
txt.value=txt.value.replace(/(\d)\s?kW(\W)/gi, '$1 kW$2');
txt.value=txt.value.replace(/(\d)\-kW(\W)/gi, '$1 kW$2');
 
    // Hertz
txt.value=txt.value.replace(/(\d)\s?(G|M|k)?hz/gi, '$1 $2Hz');
txt.value=txt.value.replace(/(\d)\-(G|M|k)?hz/gi, '$1 $2Hz');
txt.value=txt.value.replace(/khz/gi, 'kHz');
 
 
    // ohm
txt.value=txt.value.replace(/(\d)\s?(Y|Z|E|P|T|G|M|k|K|h|da|d|c|m|µ|μ|µ|n|p|f|a|z|y)?\s?(&Omega;|ohm|Ohm)s?(\W)/g, '$1 $2Ω$4');
 
//grains to grams
txt.value=txt.value.replace(/(\s)(\d{1,3}00)(?:\s|-|&nbsp;)grains([^\(\)]{2})/gi, '$1\{\{convert|$2|gr|g\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3}0)(?:\s|-|&nbsp;)grains([^\(\)]{2})/gi, '$1\{\{convert|$2|gr|g\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3})(?:\s|-|&nbsp;)grains([^\(\)]{2})/gi, '$1\{\{convert |$2|gr|g\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3}\.\d)(?:\s|-|&nbsp;)grains([^\(\)]{2})/gi, '$1\{\{convert |$2|gr|g\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3}\.\d\d)(?:\s|-|&nbsp;)grains([^\(\)]{2})/gi, '$1\{\{convert |$2|gr|g\}\}$3');
 
txt.value=txt.value.replace(/(\s)(\d{1,3}00)(?:\s|-|&nbsp;)grain([^\(\)]{2})/gi, '$1\{\{Convert|$2|gr|g|sing=on\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3}0)(?:\s|-|&nbsp;)grain([^\(\)]{2})/gi, '$1\{\{Convert|$2|gr|g|sing=on\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3})(?:\s|-|&nbsp;)grain([^\(\)]{2})/gi, '$1\{\{Convert|$2|gr|g|sing=on\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3}\.\d)(?:\s|-|&nbsp;)grain([^\(\)]{2})/gi, '$1\{\{Convert|$2|gr|g|sing=on\}\}$3');
txt.value=txt.value.replace(/(\s)(\d{1,3}\.\d\d)(?:\s|-|&nbsp;)grain([^\(\)]{2})/gi, '$1\{\{Convert|$2|gr|g|sing=on\}\}$3');
 
    // pound weight
txt.value=txt.value.replace(/\[\[\pound\s\(weight\)\|([^\]]{1,30})\]\]/gi, '[[pound (mass)|$1]]');
txt.value=txt.value.replace(/\|lbs?\.\]\]/gi, '|lb]]');
txt.value=txt.value.replace(/(\d)\s?lbs?/gi, '$1 lb');
txt.value=txt.value.replace(/(\d\+?)\s?lbs?/gi, '$1 lb');
txt.value=txt.value.replace(/(\d)&nbsp;lbs?/gi, '$1&nbsp;lb');
 
    //foot
txt.value=txt.value.replace(/(\d)\s?ft(\W)/gi, '$1 ft$2');
txt.value=txt.value.replace(/(\d)\-ft(\W)/gi, '$1 ft$2');
txt.value=txt.value.replace(/(\W)ft\.\)/gi, '$1ft)');
txt.value=txt.value.replace(/\sfeet\)/gi, ' ft)');
txt.value=txt.value.replace(/\sfoot\)/gi, ' ft)');
txt.value=txt.value.replace(/&nbsp;feet\)/gi, '&nbsp;ft)');
txt.value=txt.value.replace(/(\|[\s\d\.]{1,9})feet(\s{1,3}\()/gi, '$1ft$2');

 // square metre
    //txt.value=txt.value.replace(/([^\|])sq\.?\s?m/gi, '$1 m²');
txt.value=txt.value.replace(/(\d)(?:\s|-|&nbsp;)?(sq|square)\.?(?:\s|-|&nbsp;)?(metres|meters|metre|meter)/gi, '$1 $2 $3');
txt.value=txt.value.replace(/(\d)(?:\s|-|&nbsp;)? sq\.?(?:\s|-|&nbsp;)?(metres|meters|metre|meter)/gi, '$1 m²');
    //txt.value=txt.value.replace(/sq&nbsp;m/gi, 'm²');
 
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3}),?(000),?(000)(?:\s|-|&nbsp;)sq(?:\s|-| )m(\W[^\(\)])/gi, '$1\{\{convert|$2$3$4|m2|sqft|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^\d,\.\E])(\d{1,3}),?(000),?(000)(?:\s|-|&nbsp;)m²(\.|\,|\s[^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m2|sqft|-5 abbr=on\}\}$5');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3}),?(000),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)metres([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m2|sqft|\}\}$5');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3}),?(000),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)meters([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m2|sqft|sp=us\}\}$5');

txt.value=txt.value.replace(/([^\d,\.])(\d{1,3}),?(000),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)metre([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m2|sqft|sing=on\}\}$5');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3}),?(000),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)meter ([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m2|sqft|sing=on|sp=us \}\}$5');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3}00),?(000)(?:\s|-|&nbsp;)sq(?:\s|-| )m(\W[^\(\)])/gi, '$1\{\{convert|$2$3$4|m2|sqft|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^\d,\.\E])(\d{1,3})?,?(\d{1,3}00),?(000)(?:\s|-|&nbsp;)m²(\.|\,|\s[^\(]{2})/gi, '$1\{\{convert|$2$3$4|m2|sqft|\}\}$5');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3}00),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)metres([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m2|sqft|\}\}$5');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3}00),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)meters([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m2|sqft|sp=us\}\}$5');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3}00),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)metre([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m2|sqft|sing=on\}\}$5');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3}00),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)meter([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m2|sqft|sing=on|sp=us\}\}$5');

txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3}0),?(000)(?:\s|-|&nbsp;)sq(?:\s|-| )m(\W[^\(\)])/gi, '$1\{\{convert|$2$3$4|m2|sqft|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^\d,\.\E])(\d{1,3})?,?(\d{1,3}0),?(000)(?:\s|-|&nbsp;)m²(\.|\,|\s[^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m2|sqft|\}\}$5');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3}0),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)metres([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m2|sqft|\}\}$5');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3}0),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)meters([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m2|sqft|sp=us \}\}$5');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3}0),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)metre([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m2|sqft|sing=on\}\}$5');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3}0),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)meter([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m2|sqft|sing=on|sp=us\}\}$5');

txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)sq(?:\s|-| )m(\W[^\(\)])/gi, '$1\{\{convert|$2$3$4|m2|sqft|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^\d,\.\E])(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)m²(\.|\,|\s[^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m2|sqft|\}\}$5');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)metres([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m2|sqft|\}\}$5');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)meters([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m2|sqft|sp=us\}\}$5');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)metre([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m2|sqft|sing=on\}\}$5');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)meter([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m2|sqft|sing=on|sp=us \}\}$5');

txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)sq(?:\s|-| )m(\W[^\(\)])/gi, '$1\{\{convert|$2$3$4|m2|sqft|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^\d,\.\E])(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)m²(\.|\,|\s[^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m2|sqft|\}\}$5');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)metres([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m2|sqft|\}\}$5');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)meters([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m2|sqft|sp=us\}\}$5');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)metre([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m2|sqft|sing=on\}\}$5');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)meter([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m2|sqft|sing=on|sp=us\}\}$5');
 
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)sq(?:\s|-| )m(\W[^\(\)])/gi, '$1\{\{convert|$2$3$4|m2|sqft|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^\d,\.\E])(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)m²(\.|\,|\s[^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m2|sqft|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3}),?(\d{1,3}00)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)metres([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m2|sqft|\}\}$5');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3}),?(\d{1,3}00)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)meters([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m2|sqft|sp=us\}\}$5');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3}),?(\d{1,3}00)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)metre([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m2|sqft|sing=on\}\}$5');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3}),?(\d{1,3}00)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)meter([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m2|sqft|sing=on|sp=us\}\}$5');
 
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)sq(?:\s|-| )m(\W[^\(\)])/gi, '$1\{\{convert|$2$3$4|m2|sqft|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^\d,\.\E])(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)m²([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m2|sqft|\}\}$5');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)metres([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m2|sqft\}\}$5');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)meters([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m2|sqft|\}\}$5');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)metre([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m2|sqft|sing=on\}\}$5');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)meter([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m2|sqft|sing=on\}\}$5');
 
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})\ssq\sm([^i\(\)]{2})/gi, '$1\{\{convert|$2|m2|sqft|abbr=on\}\}$3');
txt.value=txt.value.replace(/([^\d,\.\E])(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)m²(\.|\,|\s[^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m2|sqft|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)metres ([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m2|sqft|\}\}$5');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)meters([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m2|sqft|sp=us \}\}$5');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)metre([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m2|sqft|sing=on\}\}$5');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)meter([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|m2|sqft|sing=on|sp=us\}\}$5');
 
txt.value=txt.value.replace(/([^\d,\.])(\d00)(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)sq(?:\s|-| )m(\W[^\(\)])/gi, '$1\{\{convert|$2000|m2|sqft|abbr=on\}\}$3');
txt.value=txt.value.replace(/([^\d,\.\E])(\d00)(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)m²(\.|\,|\s[^\(\)]{2})/gi, '$1\{\{convert|$2000|m2|sqft|abbr=on\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d0)(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)sq(?:\s|-| )m(\W[^\(\)])/gi, '$1\{\{convert|$2000|m2|sqft|abbr=on\}\}$3');
txt.value=txt.value.replace(/([^\d,\.\E])(\d0)(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)m²(\.|\,|\s[^\(\)]{2})/gi, '$1\{\{convert|$2000|m2|sqft|abbr=on\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d)(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)sq(?:\s|-| )m(\W[^\(\)])/gi, '$1\{\{convert|$2000|m2|sqft|abbr=on\}\}$3');
txt.value=txt.value.replace(/([^\d,\.\E])(\d)(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)m²(\.|\,|\s[^\(\)]{2})/gi, '$1\{\{convert|$2000|m2|sqft|abbr=on\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3)(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)sq(?:\s|-| )m(\W[^\(\)])/gi, '$1\{\{convert|$2000|m2|sqft|abbr=on\}\}$3');
txt.value=txt.value.replace(/([^\d,\.\E])(\d{1,3)(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)m²(\.|\,|\s[^\(\)]{2})/gi, '$1\{\{convert|$2000|m2|sqft|abbr=on\}\}$3');
 
txt.value=txt.value.replace(/([^\d,\.])(\d00)(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)metres([^\(\)]{2})/gi, '$1\{\{convert|$2000|m2|sqft|\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d0)(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)metres([^\(\)]{2})/gi, '$1\{\{convert|$2000|m2|sqft|\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d)(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)metres([^\(\)]{2})/gi, '$1\{\{convert|$2000|m2|sqft|\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3)(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)metres([^\(\)]{2})/gi, '$1\{\{convert|$2000|m2|sqft|\}\}$3');
 
txt.value=txt.value.replace(/([^\d,\.])(\d00)(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)meters([^\(\)]{2})/gi, '$1\{\{convert|$2000|m2|sqft|sp=us\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d0)(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)meters([^\(\)]{2})/gi, '$1\{\{convert|$2000|m2|sqft|sp=us\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d)(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)meters([^\(\)]{2})/gi, '$1\{\{convert|$2000|m2|sqft|sp=us\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3)(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)meters([^\(\)]{2})/gi, '$1\{\{convert|$2000|m2|sqft|sp=us\}\}$3');

txt.value=txt.value.replace(/([^\d,\.])(\d00)(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)metre([^\(\)]{2})/gi, '$1\{\{convert|$2000|m2|sqft|sing=on\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d0)(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)metre([^\(\)]{2})/gi, '$1\{\{convert|$2000|m2|sqft|sing=on\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d)(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)metre([^\(\)]{2})/gi, '$1\{\{convert|$2000|m2|sqft|sing=on\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3)(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)metre([^\(\)]{2})/gi, '$1\{\{convert|$2000|m2|sqft|sing=on\}\}$3');
 
txt.value=txt.value.replace(/([^\d,\.])(\d00)(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)meter([^\(\)]{2})/gi, '$1\{\{convert|$2000|m2|sqft|sing=on|sp=us\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d0)(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)meter([^\(\)]{2})/gi, '$1\{\{convert|$2000|m2|sqft|sing=on|sp=us\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d)(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)meter([^\(\)]{2})/gi, '$1\{\{convert|$2000|m2|sqft|sing=on|sp=us\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3)(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)meter([^\(\)]{2})/gi, '$1\{\{convert|$2000|m2|sqft|sing=on|sp=us\}\}$3');

txt.value=txt.value.replace(/([^\d,\.])(\d00)(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)sq(?:\s|-| )m(\W[^\(\)])/gi, '$1\{\{convert|$2000000|m2|sqft|abbr=on\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d0)(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)sq(?:\s|-| )m(\W[^\(\)])/gi, '$1\{\{convert|$2000000|m2|sqft|abbr=on\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d)(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)sq(?:\s|-| )m(\W[^\(\)])/gi, '$1\{\{convert|$2000000|m2|sqft|abbr=on\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3)(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)sq(?:\s|-| )m(\W[^\(\)])/gi, '$1\{\{convert|$2000000|m2|sqft|abbr=on\}\}$3');

txt.value=txt.value.replace(/([^\d,\.\E])(\d00)(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)m²(\.|\,|\s[^\(\)]{2})/gi, '$1\{\{convert|$2000000|m2|sqft|abbr=on\}\}$3');
txt.value=txt.value.replace(/([^\d,\.\E])(\d0)(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)m²(\.|\,|\s[^\(\)]{2})/gi, '$1\{\{convert|$2000000|m2|sqft|abbr=on\}\}$3');
txt.value=txt.value.replace(/([^\d,\.\E])(\d)(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)m²(\.|\,|\s[^\(\)]{2})/gi, '$1\{\{convert|$2000000|m2|sqft|abbr=on\}\}$3');
txt.value=txt.value.replace(/([^\d,\.\E])(\d{1,3)(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)m²(\.|\,|\s[^\(\)]{2})/gi, '$1\{\{convert|$2000000|m2|sqft|abbr=on\}\}$3');
 
txt.value=txt.value.replace(/([^\d,\.])(\d00)(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)metres([^\(\)]{2})/gi, '$1\{\{convert|$2000000|m2|sqft|\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d0)(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)metres([^\(\)]{2})/gi, '$1\{\{convert|$2000000|m2|sqft|\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d)(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)metres([^\(\)]{2})/gi, '$1\{\{convert|$2000000|m2|sqft|\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3)(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)metres([^\(\)]{2})/gi, '$1\{\{convert|$2000000|m2|sqft|\}\}$3');

txt.value=txt.value.replace(/([^\d,\.])(\d00)(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)meters([^\(\)]{2})/gi, '$1\{\{convert|$2000000|m2|sqft|sp=us\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d0)(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)meters([^\(\)]{2})/gi, '$1\{\{convert|$2000000|m2|sqft|sp=us\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d)(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)meters([^\(\)]{2})/gi, '$1\{\{convert|$2000000|m2|sqft|sp=us\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3)(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)meters([^\(\)]{2})/gi, '$1\{\{convert|$2000000|m2|sqft|sp=us\}\}$3');

txt.value=txt.value.replace(/([^\d,\.])(\d00)(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)metre([^\(\)]{2})/gi, '$1\{\{convert|$2000000|m2|sqft|sing=on\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d0)(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)metre([^\(\)]{2})/gi, '$1\{\{convert|$2000000|m2|sqft|sing=on\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d)(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)metre([^\(\)]{2})/gi, '$1\{\{convert|$2000000|m2|sqft|sing=on\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3)(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)metre([^\(\)]{2})/gi, '$1\{\{convert|$2000000|m2|sqft|sing=on\}\}$3');

txt.value=txt.value.replace(/([^\d,\.])(\d00)(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)meter([^\(\)]{2})/gi, '$1\{\{convert|$2000000|m2|sqft|sing=on|sp=us\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d0)(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)meter([^\(\)]{2})/gi, '$1\{\{convert|$2000000|m2|sqft|sing=on|sp=us\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d)(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)meter([^\(\)]{2})/gi, '$1\{\{convert|$2000000|m2|sqft|sing=on|sp=us\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3)(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)meter([^\(\)]{2})/gi, '$1\{\{convert|$2000000|m2|sqft|sing=on|sp=us\}\}$3');



 
    // square foot
    //txt.value=txt.value.replace(/([^\|])sq\.?\s?ft/gi, '$1sq&nbsp;ft');
txt.value=txt.value.replace(/(\d)(?:\s|-|&nbsp;)?(sq|square)\.?(?:\s|-|&nbsp;)?(ft|feet|foot)/gi, '$1 $2 $3');
txt.value=txt.value.replace(/(\d) sq (ft|feet|foot)/gi, '$1 sq&nbsp;ft');
txt.value=txt.value.replace(/ft²/gi, 'sq&nbsp;ft');
 
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3}),?(000),?(000)(?:\s|-|&nbsp;)sq(?:\s|-|&nbsp;)ft([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|sqft|m2|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3}),?(000),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)feet([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|sqft|m2|\}\}$5');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3}),?(000),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)foot([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|sqft|m2|sing=on\}\}$5');
 
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3}00),?(000)(?:\s|-|&nbsp;)sq(?:\s|-|&nbsp;)ft([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|sqft|m2|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3}00),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)feet([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|sqft|m2|\}\}$5');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3}00),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)foot([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|sqft|m2|sing=on\}\}$5');
 
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3}0),?(000)(?:\s|-|&nbsp;)sq(?:\s|-|&nbsp;)ft([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|sqft|m2|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3}0),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)feet([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|sqft|m2|\}\}$5');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3}0),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)foot([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|sqft|m2|sing=on\}\}$5');
 
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3})?,?(000)(?:\s|-|&nbsp;)sq(?:\s|-|&nbsp;)ft([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|sqft|m2|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3})?,?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)feet([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|sqft|m2|\}\}$5');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3})?,?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)foot([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|sqft|m2|sing=on\}\}$5');
 
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)sq(?:\s|-|&nbsp;)ft([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|sqft|m2|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3}),?(\d{1,3}00)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)feet([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|sqft|m2|\}\}$5');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3}),?(\d{1,3}00)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)foot([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|sqft|m2|sing=on\}\}$5');
 
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)sq(?:\s|-|&nbsp;)ft([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|sqft|m2|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)feet([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|sqft|m2|\}\}$5');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)foot([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|sqft|m2|sing=on\}\}$5');
 
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)sq(?:\s|-|&nbsp;)ft([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|sqft|m2|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)feet([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|sqft|m2|\}\}$5');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)foot([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|sqft|m2|sing=on\}\}$5');
 
txt.value=txt.value.replace(/([^\d,\.])(\d00)(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)sq(?:\s|-|&nbsp;)ft([^\(\)]{2})/gi, '$1\{\{convert|$2000|sqft|m2|abbr=on\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d0)(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)sq(?:\s|-|&nbsp;)ft([^\(\)]{2})/gi, '$1\{\{convert|$2000|sqft|m2|abbr=on\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d)(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)sq(?:\s|-|&nbsp;)ft([^\(\)]{2})/gi, '$1\{\{convert|$2000|sqft|m2|abbr=on\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3)(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)sq(?:\s|-|&nbsp;)ft([^\(\)]{2})/gi, '$1\{\{convert|$2000|sqft|m2|abbr=on\}\}$3');
 
txt.value=txt.value.replace(/([^\d,\.])(\d00)(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)feet([^\(\)]{2})/gi, '$1\{\{convert|$2000|sqft|m2|\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d0)(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)feet([^\(\)]{2})/gi, '$1\{\{convert|$2000|sqft|m2|\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d)(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)feet([^\(\)]{2})/gi, '$1\{\{convert|$2000|sqft|m2|\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3)(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)feet([^\(\)]{2})/gi, '$1\{\{convert|$2000|sqft|m2|\}\}$3');
 
txt.value=txt.value.replace(/([^\d,\.])(\d00)(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)foot([^\(\)]{2})/gi, '$1\{\{convert|$2000|sqft|m2|sing=on\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d0)(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)foot([^\(\)]{2})/gi, '$1\{\{convert|$2000|sqft|m2|sing=on\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d)(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)foot([^\(\)]{2})/gi, '$1\{\{convert|$2000|sqft|m2|sing=on\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3)(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)foot([^\(\)]{2})/gi, '$1\{\{convert|$2000|sqft|m2|sing=on\}\}$3');
 
txt.value=txt.value.replace(/([^\d,\.])(\d00)(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)sq(?:\s|-|&nbsp;)ft([^\(\)]{2})/gi, '$1\{\{convert|$2000000|sqft|m2|abbr=on\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d0)(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)sq(?:\s|-|&nbsp;)ft([^\(\)]{2})/gi, '$1\{\{convert|$2000000|sqft|m2|abbr=on\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d)(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)sq(?:\s|-|&nbsp;)ft([^\(\)]{2})/gi, '$1\{\{convert|$2000000|sqft|m2|abbr=on\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3)(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)sq(?:\s|-|&nbsp;)ft([^\(\)]{2})/gi, '$1\{\{convert|$2000000|sqft|m2|abbr=on\}\}$3');
 
txt.value=txt.value.replace(/([^\d,\.])(\d00)(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)feet([^\(\)]{2})/gi, '$1\{\{convert|$2000000|sqft|m2|\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d0)(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)feet([^\(\)]{2})/gi, '$1\{\{convert|$2000000|sqft|m2|\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d)(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)feet([^\(\)]{2})/gi, '$1\{\{convert|$2000000|sqft|m2|\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3)(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)feet([^\(\)]{2})/gi, '$1\{\{convert|$2000000|sqft|m2|\}\}$3');
 
txt.value=txt.value.replace(/([^\d,\.])(\d00)(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)foot([^\(\)]{2})/gi, '$1\{\{convert|$2000000|sqft|m2|sing=on\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d0)(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)foot([^\(\)]{2})/gi, '$1\{\{convert|$2000000|sqft|m2|sing=on\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d)(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)foot([^\(\)]{2})/gi, '$1\{\{convert|$2000000|sqft|m2|sing=on\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3)(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)foot([^\(\)]{2})/gi, '$1\{\{convert|$2000000|sqft|m2|sing=on\}\}$3');

 
//feet per second
//feet per second:plural
txt.value=txt.value.replace(/(\s)(\d{1,3}00)?,?(000)(?:\s|-|&nbsp;)feet\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3|ft/s|m/s|\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3}0)?,?(000)(?:\s|-|&nbsp;)feet\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3|ft/s|m/s|\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(000)(?:\s|-|&nbsp;)feet\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3|ft/s|m/s|\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)feet\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3|ft/s|m/s|\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)feet\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3|ft/s|m/s|\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)feet\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3|ft/s|m/s|\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})(\.\d)(?:\s|-|&nbsp;)feet\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|ft/s|m/s|\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})(\.\d\d)(?:\s|-|&nbsp;)feet\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|ft/s|m/s|\}\}$5');
//feet per second:singular
txt.value=txt.value.replace(/(\s)(\d{1,3}00)?,?(000)(?:\s|-|&nbsp;)foot\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3|ft/s|m/s|sing=on\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3}0)?,?(000)(?:\s|-|&nbsp;)foot\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3|ft/s|m/s|sing=on\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(000)(?:\s|-|&nbsp;)foot\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3|ft/s|m/s|sing=on\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)foot\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3|ft/s|m/s|sing=on\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)foot\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3|ft/s|m/s|sing=on\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)foot\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3|ft/s|m/s|sing=on\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})(\.\d)(?:\s|-|&nbsp;)foot\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|ft/s|m/s|sing=on\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})(\.\d\d)(?:\s|-|&nbsp;)foot\sper\ssecond([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|ft/s|m/s|sing=on\}\}$5');
//feet per second:abbreviated
txt.value=txt.value.replace(/(\s)(\d{1,3}00)?,?(000)(?:\s|-|&nbsp;)ft\/s([^\(\)]{2})/gi, '$1\{\{convert|$2$3|ft/s|m/s|abbr=on\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3}0)?,?(000)(?:\s|-|&nbsp;)ft\/s([^\(\)]{2})/gi, '$1\{\{convert|$2$3|ft/s|m/s|abbr=on\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(000)(?:\s|-|&nbsp;)ft\/s([^\(\)]{2})/gi, '$1\{\{convert|$2$3|ft/s|m/s|abbr=on\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)ft\/s([^\(\)]{2})/gi, '$1\{\{convert|$2$3|ft/s|m/s|abbr=on\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)ft\/s([^\(\)]{2})/gi, '$1\{\{convert|$2$3|ft/s|m/s|abbr=on\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)ft\/s([^\(\)]{2})/gi, '$1\{\{convert|$2$3|ft/s|m/s|abbr=on\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})(\.\d)(?:\s|-|&nbsp;)ft\/s([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|ft/s|m/s|abbr=on\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})(\.\d\d)(?:\s|-|&nbsp;)ft\/s([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|ft/s|m/s|abbr=on\}\}$5');
 
    // foot and inch
txt.value=txt.value.replace(/(ength[.]{1,3})(\d{1,4})\s?['’]\s?(\d{1,3})\s?["”]/gi, '$1$2 ft $3 in');
txt.value=txt.value.replace(/(idth[.]{1,3})(\d{1,4})\s?['’]\s?(\d{1,3})\s?["”]/gi, '$1$2 ft $3 in');
txt.value=txt.value.replace(/([\(\|:]\s?\d{1,4})\s?['’]\s?(\d{1,3})\s?["”]([^NESW])/g, '$1 ft $2 in$3');
txt.value=txt.value.replace(/(\d)\s?ft\s?(\d{1,3})\s?in/gi, '$1 ft $2 in');
 
 
    // yard
txt.value=txt.value.replace(/(\d)\s?yds(\W)/gi, '$1 yd$2');
txt.value=txt.value.replace(/(\d)&nbsp;yds(\W)/gi, '$1&nbsp;yd$2');
txt.value=txt.value.replace(/sq\.?\s?yds?/gi, 'sq yd');
txt.value=txt.value.replace(/yd\.\)/gi, 'yd)');
//yards: plural
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(000),?(000)(?:\s|-|&nbsp;)yards([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|yd|m|\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}00),?(000)(?:\s|-|&nbsp;)yards([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|yd|m|\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}0),?(000)(?:\s|-|&nbsp;)yards([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|yd|m|\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)yards([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|yd|m|\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)yards([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|yd|m|\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)yards([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|yd|m|\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)yards([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|yd|m|\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d)(?:\s|-|&nbsp;)yards([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4$5|yd|m|\}\}$6');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d\d)(?:\s|-|&nbsp;)yards([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4$5|yd|m|\}\}$6');
 
//yards: singular
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(000),?(000)(?:\s|-|&nbsp;)yard(\s[^\(\/])/gi, '$1\{\{convert|$2$3$4|yd|m|sing=on\}\}$5');
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(\d{1,3}00),?(000)(?:\s|-|&nbsp;)yard(\s[^\(\/])/gi, '$1\{\{convert|$2$3$4|yd|m|sing=on\}\}$5');
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(\d{1,3}0),?(000)(?:\s|-|&nbsp;)yard(\s[^\(\/])/gi, '$1\{\{convert|$2$3$4|yd|m|sing=on\}\}$5');
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)yard(\s[^\(\/])/gi, '$1\{\{convert|$2$3$4|yd|m|sing=on\}\}$5');
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)yard(\s[^\(\/])/gi, '$1\{\{convert|$2$3$4|yd|m|sing=on\}\}$5');
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)yard(\s[^\(\/])/gi, '$1\{\{convert|$2$3$4|yd|m|sing=on\}\}$5');
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)yard(\s[^\(\/])/gi, '$1\{\{convert|$2$3$4|yd|m|sing=on\}\}$5');
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)yard(\s[^\(\/])/gi, '$1\{\{convert|$2$3$4|yd|m|sing=on\}\}$5');
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d)(?:\s|-|&nbsp;)yard(\s[^\(\/])/gi, '$1\{\{convert|$2$3$4$5|yd|m|sing=on\}\}$6');
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d\d)(?:\s|-|&nbsp;)yard(\s[^\(\/])/gi, '$1\{\{convert|$2$3$4$5|yd|m|sing=on\}\}$6');
//yards: abbreviated
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(000),?(000)(?:\s|-|&nbsp;)yd(\,|\s[^\(\/])/gi, '$1\{\{convert|$2$3$4|yd|m|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(\d{1,3}00),?(000)(?:\s|-|&nbsp;)yd(\,|\s[^\(\/])/gi, '$1\{\{convert|$2$3$4|yd|m|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(\d{1,3}0),?(000)(?:\s|-|&nbsp;)yd(\,|\s[^\(\/])/gi, '$1\{\{convert|$2$3$4|yd|m|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)yd(\,|\s[^\(\/])/gi, '$1\{\{convert|$2$3$4|yd|m|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)yd(\,|\s[^\(\/])/gi, '$1\{\{convert|$2$3$4|yd|m|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)yd(\,|\s[^\(\/])/gi, '$1\{\{convert|$2$3$4|yd|m|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)yd(\,|\s[^\(\/])/gi, '$1\{\{convert|$2$3$4|yd|m|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d)(?:\s|-|&nbsp;)yd(\,|\s[^\(\/])/gi, '$1\{\{convert|$2$3$4$5|yd|m|abbr=on\}\}$6');
txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d\d)(?:\s|-|&nbsp;)yd(\,|\s[^\(\/])/gi, '$1\{\{convert|$2$3$4$5|yd|m|abbr=on\}\}$6');
//yards: in full
txt.value=txt.value.replace(/([^y]\sone(?:\s|-|&nbsp;)yards?)(\s[^\(\)]{2})/gi, '$1 (1&nbsp;m)$2');
txt.value=txt.value.replace(/([^y]\stwo(?:\s|-|&nbsp;)yards?)(\s[^\(\)]{2})/gi, '$1 (2&nbsp;m)$2');
txt.value=txt.value.replace(/([^y]\sthree(?:\s|-|&nbsp;)yards?)(\s[^\(\)]{2})/gi, '$1 (3&nbsp;m)$2');
txt.value=txt.value.replace(/([^y]\sfour(?:\s|-|&nbsp;)yards?)(\s[^\(\)]{2})/gi, '$1 (4&nbsp;m)$2');
txt.value=txt.value.replace(/([^y]\sfive(?:\s|-|&nbsp;)yards?)(\s[^\(\)]{2})/gi, '$1 (5&nbsp;m)$2');
txt.value=txt.value.replace(/([^y]\ssix(?:\s|-|&nbsp;)yards?)(\s[^\(\)]{2})/gi, '$1 (5&nbsp;m)$2');
txt.value=txt.value.replace(/([^y]\sseven(?:\s|-|&nbsp;)yards?)(\s[^\(\)]{2})/gi, '$1 (6&nbsp;m)$2');
txt.value=txt.value.replace(/([^y]\seight(?:\s|-|&nbsp;)yards?)(\s[^\(\)]{2})/gi, '$1 (7&nbsp;m)$2');
txt.value=txt.value.replace(/([^y]\snine(?:\s|-|&nbsp;)yards?)(\s[^\(\)]{2})/gi, '$1 (8&nbsp;m)$2');
txt.value=txt.value.replace(/([^y]\sten(?:\s|-|&nbsp;)yards?)(\s[^\(\)]{2})/gi, '$1 (9&nbsp;m)$2');
txt.value=txt.value.replace(/([^y]\seleven(?:\s|-|&nbsp;)yards?)(\s[^\(\)]{2})/gi, '$1 (10&nbsp;m)$2');
txt.value=txt.value.replace(/([^y]\stwelve(?:\s|-|&nbsp;)yards?)(\s[^\(\)]{2})/gi, '$1 (11&nbsp;m)$2');
txt.value=txt.value.replace(/([^y]\sthirteen(?:\s|-|&nbsp;)yards?)(\s[^\(\)]{2})/gi, '$1 (12&nbsp;m)$2');
txt.value=txt.value.replace(/([^y]\sfourteen(?:\s|-|&nbsp;)yards?)(\s[^\(\)]{2})/gi, '$1 (13&nbsp;m)$2');
txt.value=txt.value.replace(/([^y]\sfifteen(?:\s|-|&nbsp;)yards?)(\s[^\(\)]{2})/gi, '$1 (14&nbsp;m)$2');
txt.value=txt.value.replace(/([^y]\ssixteen(?:\s|-|&nbsp;)yards?)(\s[^\(\)]{2})/gi, '$1 (15&nbsp;m)$2');
txt.value=txt.value.replace(/([^y]\sseventeen(?:\s|-|&nbsp;)yards?)(\s[^\(\)]{2})/gi, '$1 (16&nbsp;m)$2');
txt.value=txt.value.replace(/([^y]\seighteen(?:\s|-|&nbsp;)yards?)(\s[^\(\)]{2})/gi, '$1 (16&nbsp;m)$2');
txt.value=txt.value.replace(/([^y]\snineteen(?:\s|-|&nbsp;)yards?)(\s[^\(\)]{2})/gi, '$1 (17&nbsp;m)$2');
txt.value=txt.value.replace(/([^y]\stwenty(?:\s|-|&nbsp;)yards?)(\s[^\(\)]{2})/gi, '$1 (18&nbsp;m)$2');
 
// knot
txt.value=txt.value.replace(/(\d)(\s|-|&nbsp;)kts(\W)/gi, '$1$2knots$3');
txt.value=txt.value.replace(/(\d)(\s|-|&nbsp;)kt(\W)/gi, '$1$2knots$3');
txt.value=txt.value.replace(/(\d)(\s|-|&nbsp;)knt(\W)/gi, '$1$2knots$3');
 
//nautical mile
txt.value=txt.value.replace(/(\d)(?:\s|-|&nbsp;)miles\s\at\s(\d\d?(?:\s|-|&nbsp;)knots|\{\{convert\|[\d\.]{1,9}\|kn)/gi, '$1 nautical miles at $2');
txt.value=txt.value.replace(/(\d)(?:\s|-|&nbsp;)mi\s\at\s(\d\d?(?:\s|-|&nbsp;)knots|\{\{convert\|[\d\.]{1,9}\|kn)/gi, '$1 nmi at $2 knots');
txt.value=txt.value.replace(/(\d)(?:\s|-|&nbsp;)nm\s\at\s(\d\d?(?:\s|-|&nbsp;)knots|\{\{convert\|[\d\.]{1,9}\|kn)/gi, '$1 nmi at $2 knots');
//nautical mile: plural
txt.value=txt.value.replace(/([^\d\(\)][^\d\(\)])(\d{1,3})?,?(000),?(000)(?:\s|-|&nbsp;)nautical(?:\s|-|&nbsp;)miles([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|nmi|km mi|\}\}$5');
txt.value=txt.value.replace(/([^\d\(\)][^\d\(\)])(\d{1,3})?,?(\d{1,3}00),?(000)(?:\s|-|&nbsp;)nautical(?:\s|-|&nbsp;)miles([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|nmi|km mi|\}\}$5');
txt.value=txt.value.replace(/([^\d\(\)][^\d\(\)])(\d{1,3})?,?(\d{1,3}0),?(000)(?:\s|-|&nbsp;)nautical(?:\s|-|&nbsp;)miles([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|nmi|km mi|\}\}$5');
txt.value=txt.value.replace(/([^\d\(\)][^\d\(\)])(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)nautical(?:\s|-|&nbsp;)miles([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|nmi|km mi|\}\}$5');
txt.value=txt.value.replace(/([^\d\(\)][^\d\(\)])(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)nautical(?:\s|-|&nbsp;)miles([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|nmi|km mi|\}\}$5');
txt.value=txt.value.replace(/([^\d\(\)][^\d\(\)])(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)nautical(?:\s|-|&nbsp;)miles([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|nmi|km mi|\}\}$5');
txt.value=txt.value.replace(/([^\d\(\)][^\d\(\)])(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)nautical(?:\s|-|&nbsp;)miles([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4|nmi|km mi|\}\}$5');
txt.value=txt.value.replace(/([^\d\(\)][^\d\(\)])(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d)(?:\s|-|&nbsp;)nautical(?:\s|-|&nbsp;)miles([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4$5|nmi|km mi|\}\}$6');
txt.value=txt.value.replace(/([^\d\(\)][^\d\(\)])(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d\d)(?:\s|-|&nbsp;)nautical(?:\s|-|&nbsp;)miles([^\(\)]{2})/gi, '$1\{\{convert|$2$3$4$5|nmi|km mi|\}\}$6');
//nautical mile: singular
txt.value=txt.value.replace(/([^\d\(\)][^\d\(\)])(\d{1,3})?,?(000),?(000)(?:\s|-|&nbsp;)nautical(?:\s|-|&nbsp;)mile([^s\(\)][^\(\)])/gi, '$1\{\{convert|$2$3$4|nmi|km mi|sing=on\}\}$5');
txt.value=txt.value.replace(/([^\d\(\)][^\d\(\)])(\d{1,3})?,?(\d{1,3}00),?(000)(?:\s|-|&nbsp;)nautical(?:\s|-|&nbsp;)mile([^s\(\)][^\(\)])/gi, '$1\{\{convert|$2$3$4|nmi|km mi|sing=on\}\}$5');
txt.value=txt.value.replace(/([^\d\(\)][^\d\(\)])(\d{1,3})?,?(\d{1,3}0),?(000)(?:\s|-|&nbsp;)nautical(?:\s|-|&nbsp;)mile([^s\(\)][^\(\)])/gi, '$1\{\{convert|$2$3$4|nmi|km mi|sing=on\}\}$5');
txt.value=txt.value.replace(/([^\d\(\)][^\d\(\)])(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)nautical(?:\s|-|&nbsp;)mile([^s\(\)][^\(\)])/gi, '$1\{\{convert|$2$3$4|nmi|km mi|sing=on\}\}$5');
txt.value=txt.value.replace(/([^\d\(\)][^\d\(\)])(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)nautical(?:\s|-|&nbsp;)mile([^s\(\)][^\(\)])/gi, '$1\{\{convert|$2$3$4|nmi|km mi|sing=on\}\}$5');
txt.value=txt.value.replace(/([^\d\(\)][^\d\(\)])(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)nautical(?:\s|-|&nbsp;)mile([^s\(\)][^\(\)])/gi, '$1\{\{convert|$2$3$4|nmi|km mi|sing=on\}\}$5');
txt.value=txt.value.replace(/([^\d\(\)][^\d\(\)])(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)nautical(?:\s|-|&nbsp;)mile([^s\(\)][^\(\)])/gi, '$1\{\{convert|$2$3$4|nmi|km mi|sing=on\}\}$5');
txt.value=txt.value.replace(/([^\d\(\)][^\d\(\)])(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)nautical(?:\s|-|&nbsp;)mile([^s\(\)][^\(\)])/gi, '$1\{\{convert|$2$3$4|nmi|km mi|sing=on\}\}$5');
txt.value=txt.value.replace(/([^\d\(\)][^\d\(\)])(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d)(?:\s|-|&nbsp;)nautical(?:\s|-|&nbsp;)mile([^s\(\)][^\(\)])/gi, '$1\{\{convert|$2$3$4$5|nmi|km mi|sing=on\}\}$6');
txt.value=txt.value.replace(/([^\d\(\)][^\d\(\)])(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d\d)(?:\s|-|&nbsp;)nautical(?:\s|-|&nbsp;)mile([^s\(\)][^\(\)])/gi, '$1\{\{convert|$2$3$4$5|nmi|km mi|sing=on\}\}$6');
//nautical mile: abbreviated
txt.value=txt.value.replace(/([^\d\(\)][^\d\(\)])(\d{1,3})?,?(000),?(000)(?:\s|-|&nbsp;)nmi(\s[^\(\)])/gi, '$1\{\{convert|$2$3$4|nmi|km mi|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^\d\(\)][^\d\(\)])(\d{1,3})?,?(\d{1,3}00),?(000)(?:\s|-|&nbsp;)nmi(\s[^\(\)])/gi, '$1\{\{convert|$2$3$4|nmi|km mi|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^\d\(\)][^\d\(\)])(\d{1,3})?,?(\d{1,3}0),?(000)(?:\s|-|&nbsp;)nmi(\s[^\(\)])/gi, '$1\{\{convert|$2$3$4|nmi|km mi|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^\d\(\)][^\d\(\)])(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)nmi(\s[^\(\)])/gi, '$1\{\{convert|$2$3$4|nmi|km mi|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^\d\(\)][^\d\(\)])(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)nmi(\s[^\(\)])/gi, '$1\{\{convert|$2$3$4|nmi|km mi|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^\d\(\)][^\d\(\)])(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)nmi(\s[^\(\)])/gi, '$1\{\{convert|$2$3$4|nmi|km mi|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^\d\(\)][^\d\(\)])(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)nmi(\s[^\(\)])/gi, '$1\{\{convert|$2$3$4|nmi|km mi|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^\d\(\)][^\d\(\)])(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d)(?:\s|-|&nbsp;)nmi(\s[^\(\)])/gi, '$1\{\{convert|$2$3$4$5|nmi|km mi|abbr=on\}\}$6');
txt.value=txt.value.replace(/([^\d\(\)][^\d\(\)])(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d\d)(?:\s|-|&nbsp;)nmi(\s[^\(\)])/gi, '$1\{\{convert|$2$3$4$5|nmi|km mi|abbr=on\}\}$6');
//nautical mile: in full
txt.value=txt.value.replace(/([^y]\sone(?:\s|-|&nbsp;)nautical(?:\s|-|&nbsp;)miles?)(\s[^p\(\)]{2})/gi, '$1 (1.9 km)$2');
txt.value=txt.value.replace(/([^y]\stwo(?:\s|-|&nbsp;)nautical(?:\s|-|&nbsp;)miles?)(\s[^p\(\)]{2})/gi, '$1 (4 km)$2');
txt.value=txt.value.replace(/([^y]\sthree(?:\s|-|&nbsp;)nautical(?:\s|-|&nbsp;)miles?)(\s[^p\(\)]{2})/gi, '$1 (6 km)$2');
txt.value=txt.value.replace(/([^y]\sfour(?:\s|-|&nbsp;)nautical(?:\s|-|&nbsp;)miles?)(\s[^p\(\)]{2})/gi, '$1 (7 km)$2');
txt.value=txt.value.replace(/([^y]\sfive(?:\s|-|&nbsp;)nautical(?:\s|-|&nbsp;)miles?)(\s[^p\(\)]{2})/gi, '$1 (9 km)$2');
txt.value=txt.value.replace(/([^y]\ssix(?:\s|-|&nbsp;)nautical(?:\s|-|&nbsp;)miles?)(\s[^p\(\)]{2})/gi, '$1 (11 km)$2');
txt.value=txt.value.replace(/([^y]\sseven(?:\s|-|&nbsp;)nautical(?:\s|-|&nbsp;)miles?)(\s[^p\(\)]{2})/gi, '$1 (13 km)$2');
txt.value=txt.value.replace(/([^y]\seight(?:\s|-|&nbsp;)nautical(?:\s|-|&nbsp;)miles?)(\s[^p\(\)]{2})/gi, '$1 (15 km)$2');
txt.value=txt.value.replace(/([^y]\snine(?:\s|-|&nbsp;)nautical(?:\s|-|&nbsp;)miles?)(\s[^p\(\)]{2})/gi, '$1 (17 km)$2');
txt.value=txt.value.replace(/([^y]\sten(?:\s|-|&nbsp;)nautical(?:\s|-|&nbsp;)miles?)(\s[^p\(\)]{2})/gi, '$1 (19 km)$2');
txt.value=txt.value.replace(/([^y]\seleven(?:\s|-|&nbsp;)nautical(?:\s|-|&nbsp;)miles?)(\s[^p\(\)]{2})/gi, '$1 (20 km)$2');
txt.value=txt.value.replace(/([^y]\stwelve(?:\s|-|&nbsp;)nautical(?:\s|-|&nbsp;)miles?)(\s[^p\(\)]{2})/gi, '$1 (22 km)$2');
txt.value=txt.value.replace(/([^y]\sthirteen(?:\s|-|&nbsp;)nautical(?:\s|-|&nbsp;)miles?)(\s[^p\(\)]{2})/gi, '$1 (24 km)$2');
txt.value=txt.value.replace(/([^y]\sfourteen(?:\s|-|&nbsp;)nautical(?:\s|-|&nbsp;)miles?)(\s[^p\(\)]{2})/gi, '$1 (26 km)$2');
txt.value=txt.value.replace(/([^y]\sfifteen(?:\s|-|&nbsp;)nautical(?:\s|-|&nbsp;)miles?)(\s[^p\(\)]{2})/gi, '$1 (28 km)$2');
txt.value=txt.value.replace(/([^y]\ssixteen(?:\s|-|&nbsp;)nautical(?:\s|-|&nbsp;)miles?)(\s[^p\(\)]{2})/gi, '$1 (30 km)$2');
txt.value=txt.value.replace(/([^y]\sseventeen(?:\s|-|&nbsp;)nautical(?:\s|-|&nbsp;)miles?)(\s[^p\(\)]{2})/gi, '$1 (31 km)$2');
txt.value=txt.value.replace(/([^y]\seighteen(?:\s|-|&nbsp;)nautical(?:\s|-|&nbsp;)miles?)(\s[^p\(\)]{2})/gi, '$1 (33 km)$2');
txt.value=txt.value.replace(/([^y]\snineteen(?:\s|-|&nbsp;)nautical(?:\s|-|&nbsp;)miles?)(\s[^p\(\)]{2})/gi, '$1 (35 km)$2');
txt.value=txt.value.replace(/([^y]\stwenty(?:\s|-|&nbsp;)nautical(?:\s|-|&nbsp;)miles?)(\s[^p\(\)]{2})/gi, '$1 (37 km)$2');
 
//knot - plural
txt.value=txt.value.replace(/([^\d\(\)][^\d\(\)])(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)knots([^\(\)][^\(\)])/gi, '$1\{\{convert|$2$3|kn|km/h mph|\}\}$4');
txt.value=txt.value.replace(/([^\d\(\)][^\d\(\)])(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)knots([^\(\)][^\(\)])/gi, '$1\{\{convert|$2$3|kn|km/h mph|\}\}$4');
txt.value=txt.value.replace(/([^\d\(\)][^\d\(\)])(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)knots([^\(\)][^\(\)])/gi, '$1\{\{convert|$2$3|kn|km/h mph|\}\}$4');
txt.value=txt.value.replace(/([^\d\(\)][^\d\(\)])(\d{1,3})?,?(\d{1,3})(\.\d)(?:\s|-|&nbsp;)knots([^\(\)][^\(\)])/gi, '$1\{\{convert|$2$3$4|kn|km/h mph|\}\}$5');
//knot - singular
txt.value=txt.value.replace(/([^\d\(\)][^\d\(\)])(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)knot([^s\(\)][^\(\)])/gi, '$1\{\{convert|$2$3|kn|km/h mph|sing=on\}\}$4');
txt.value=txt.value.replace(/([^\d\(\)][^\d\(\)])(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)knot([^s\(\)][^\(\)])/gi, '$1\{\{convert|$2$3|kn|km/h mph|sing=on\}\}$4');
txt.value=txt.value.replace(/([^\d\(\)][^\d\(\)])(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)knot([^s\(\)][^\(\)])/gi, '$1\{\{convert|$2$3|kn|km/h mph|sing=on\}\}$4');
txt.value=txt.value.replace(/([^\d\(\)][^\d\(\)])(\d{1,3})?,?(\d{1,3})(\.\d)(?:\s|-|&nbsp;)knot([^s\(\)][^\(\)])/gi, '$1\{\{convert|$2$3$4|kn|km/h mph|sing=on\}\}$5');
 
    //mile
txt.value=txt.value.replace(/\[\[(mile)\]\]/gi, '$1');
txt.value=txt.value.replace(/(\d)-(mile)/gi, '$1 $2');
//miles: plural
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(000),?(000)(?:\s|-|&nbsp;)miles([^p\(\)]{2})/gi, '$1\{\{convert|$2$3$4|mi|km|\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3}00),?(000)(?:\s|-|&nbsp;)miles([^p\(\)]{2})/gi, '$1\{\{convert|$2$3$4|mi|km|\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3}0),?(000)(?:\s|-|&nbsp;)miles([^p\(\)]{2})/gi, '$1\{\{convert|$2$3$4|mi|km|\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)miles([^p\(\)]{2})/gi, '$1\{\{convert|$2$3$4|mi|km|\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)miles([^p\(\)]{2})/gi, '$1\{\{convert|$2$3$4|mi|km|\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)miles([^p\(\)]{2})/gi, '$1\{\{convert|$2$3$4|mi|km|\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)miles([^p\(\)]{2})/gi, '$1\{\{convert|$2$3$4|mi|km|\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d)(?:\s|-|&nbsp;)miles([^p\(\)]{2})/gi, '$1\{\{convert|$2$3$4$5|mi|km|\}\}$6');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d\d)(?:\s|-|&nbsp;)miles([^p\(\)]{2})/gi, '$1\{\{convert|$2$3$4$5|mi|km|\}\}$6');
//miles: singular
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(000),?(000)(?:\s|-|&nbsp;)mile([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4|mi|km|sing=on\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3}00),?(000)(?:\s|-|&nbsp;)mile([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4|mi|km|sing=on\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3}0),?(000)(?:\s|-|&nbsp;)mile([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4|mi|km|sing=on\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)mile([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4|mi|km|sing=on\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)mile([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4|mi|km|sing=on\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)mile([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4|mi|km|sing=on\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)mile([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4|mi|km|sing=on\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)mile([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4|mi|km|sing=on\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d)(?:\s|-|&nbsp;)mile([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4$5|mi|km|sing=on\}\}$6');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d\d)(?:\s|-|&nbsp;)mile([^s\(\)][^p\(\)])/gi, '$1\{\{convert|$2$3$4$5|mi|km|sing=on\}\}$6');
//miles: abbreviated
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(000),?(000)(?:\s|-|&nbsp;)mi(\,|\s[^\(\)])/gi, '$1\{\{convert|$2$3$4|mi|km|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3}00),?(000)(?:\s|-|&nbsp;)mi(\,|\s[^\(\)])/gi, '$1\{\{convert|$2$3$4|mi|km|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3}0),?(000)(?:\s|-|&nbsp;)mi(\,|\s[^\(\)])/gi, '$1\{\{convert|$2$3$4|mi|km|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)mi(\,|\s[^\(\)])/gi, '$1\{\{convert|$2$3$4|mi|km|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)mi(\,|\s[^\(\)])/gi, '$1\{\{convert|$2$3$4|mi|km|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)mi(\,|\s[^\(\)])/gi, '$1\{\{convert|$2$3$4|mi|km|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)mi(\,|\s[^\(\)])/gi, '$1\{\{convert|$2$3$4|mi|km|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d)(?:\s|-|&nbsp;)mi(\,|\s[^\(\)])/gi, '$1\{\{convert|$2$3$4$5|mi|km|abbr=on\}\}$6');
txt.value=txt.value.replace(/([^r\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d\d)(?:\s|-|&nbsp;)mi(\,|\s[^\(\)])/gi, '$1\{\{convert|$2$3$4$5|mi|km|abbr=on\}\}$6');
//miles: in full
txt.value=txt.value.replace(/([^y]\sone(?:\s|-|&nbsp;)miles?)(\s[^p\(\)]{2})/gi, '$1 (1.6 km)$2');
txt.value=txt.value.replace(/([^y]\stwo(?:\s|-|&nbsp;)miles?)(\s[^p\(\)]{2})/gi, '$1 (3 km)$2');
txt.value=txt.value.replace(/([^y]\sthree(?:\s|-|&nbsp;)miles?)(\s[^p\(\)]{2})/gi, '$1 (5 km)$2');
txt.value=txt.value.replace(/([^y]\sfour(?:\s|-|&nbsp;)miles?)(\s[^p\(\)]{2})/gi, '$1 (6 km)$2');
txt.value=txt.value.replace(/([^y]\sfive(?:\s|-|&nbsp;)miles?)(\s[^p\(\)]{2})/gi, '$1 (8 km)$2');
txt.value=txt.value.replace(/([^y]\ssix(?:\s|-|&nbsp;)miles?)(\s[^p\(\)]{2})/gi, '$1 (10 km)$2');
txt.value=txt.value.replace(/([^y]\sseven(?:\s|-|&nbsp;)miles?)(\s[^p\(\)]{2})/gi, '$1 (11 km)$2');
txt.value=txt.value.replace(/([^y]\seight(?:\s|-|&nbsp;)miles?)(\s[^p\(\)]{2})/gi, '$1 (13 km)$2');
txt.value=txt.value.replace(/([^y]\snine(?:\s|-|&nbsp;)miles?)(\s[^p\(\)]{2})/gi, '$1 (14 km)$2');
txt.value=txt.value.replace(/([^y]\sten(?:\s|-|&nbsp;)miles?)(\s[^p\(\)]{2})/gi, '$1 (16 km)$2');
txt.value=txt.value.replace(/([^y]\seleven(?:\s|-|&nbsp;)miles?)(\s[^p\(\)]{2})/gi, '$1 (18 km)$2');
txt.value=txt.value.replace(/([^y]\stwelve(?:\s|-|&nbsp;)miles?)(\s[^p\(\)]{2})/gi, '$1 (19 km)$2');
txt.value=txt.value.replace(/([^y]\sthirteen(?:\s|-|&nbsp;)miles?)(\s[^p\(\)]{2})/gi, '$1 (19 km)$2');
txt.value=txt.value.replace(/([^y]\sfourteen(?:\s|-|&nbsp;)miles?)(\s[^p\(\)]{2})/gi, '$1 (21 km)$2');
txt.value=txt.value.replace(/([^y]\sfifteen(?:\s|-|&nbsp;)miles?)(\s[^p\(\)]{2})/gi, '$1 (24 km)$2');
txt.value=txt.value.replace(/([^y]\ssixteen(?:\s|-|&nbsp;)miles?)(\s[^p\(\)]{2})/gi, '$1 (26 km)$2');
txt.value=txt.value.replace(/([^y]\sseventeen(?:\s|-|&nbsp;)miles?)(\s[^p\(\)]{2})/gi, '$1 (27 km)$2');
txt.value=txt.value.replace(/([^y]\seighteen(?:\s|-|&nbsp;)miles?)(\s[^p\(\)]{2})/gi, '$1 (29 km)$2');
txt.value=txt.value.replace(/([^y]\snineteen(?:\s|-|&nbsp;)miles?)(\s[^p\(\)]{2})/gi, '$1 (30 km)$2');
txt.value=txt.value.replace(/([^y]\stwenty(?:\s|-|&nbsp;)miles?)(\s[^p\(\)]{2})/gi, '$1 (32 km)$2');
 
    //mile per hour
txt.value=txt.value.replace(/m\.p\.h\.(\W)/g, 'mph$1');
txt.value=txt.value.replace(/(\d)\s?mph/gi, '$1 mph');
txt.value=txt.value.replace(/(\d)\-mph/gi, '$1 mph');
 
txt.value=txt.value.replace(/([^\d]\s)(\d{1,3}00),?(000)(?:\s|-|&nbsp;)mph([^\(\)]{3})/gi, '$1\{\{convert|$2$3|mph|km/h|abbr=on\}\}$4');
txt.value=txt.value.replace(/([^\d]\s)(\d{1,3}0),?(000)(?:\s|-|&nbsp;)mph([^\(\)]{3})/gi, '$1\{\{convert|$2$3|mph|km/h|abbr=on\}\}$4');
txt.value=txt.value.replace(/([^\d]\s)(\d{1,3}),?(000)(?:\s|-|&nbsp;)mph([^\(\)]{3})/gi, '$1\{\{convert|$2$3|mph|km/h|abbr=on\}\}$4');
txt.value=txt.value.replace(/([^\d]\s)(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)mph([^\(\)]{3})/gi, '$1\{\{convert|$2$3|mph|km/h|abbr=on\}\}$4');
txt.value=txt.value.replace(/([^\d]\s)(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)mph([^\(\)]{3})/gi, '$1\{\{convert|$2$3|mph|km/h|abbr=on\}\}$4');
txt.value=txt.value.replace(/([^\d]\s)(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)mph([^\(\)]{3})/gi, '$1\{\{convert|$2$3|mph|km/h|abbr=on\}\}$4');
txt.value=txt.value.replace(/([^\d]\s)(\d{1,3}\.\d\d)(?:\s|-|&nbsp;)mph([^\(\)]{3})/gi, '$1\{\{convert|$2|mph|km/h|abbr=on\}\}$3');
txt.value=txt.value.replace(/([^\d]\s)(\d{1,3}\.\d\d\d)(?:\s|-|&nbsp;)mph([^\(\)]{3})/gi, '$1\{\{convert|$2|mph|km/h|abbr=on\}\}$3');
 
    // square mile
txt.value=txt.value.replace(/([^\|])sq\.?\s?mi/gi, '$1sq mi');
txt.value=txt.value.replace(/sq\.?&nbsp;mi/gi, 'sq&nbsp;mi');
txt.value=txt.value.replace(/mile²/gi, 'sq&nbsp;mi');
txt.value=txt.value.replace(/miles²/gi, 'sq&nbsp;mi');
txt.value=txt.value.replace(/mi²/gi, 'sq&nbsp;mi');
txt.value=txt.value.replace(/mi&sup2;/gi, 'sq&nbsp;mi');
txt.value=txt.value.replace(/\[\[(square\smile)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[square\smile\|(sq\smi)\]\]/gi, '$1');
txt.value=txt.value.replace(/(sq)(?:\s|-|&nbsp;)(mile)/gi, '$1uare $2');
    // square mile:plural
txt.value=txt.value.replace(/(\s)(\d{1,3}),?(000),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)miles([^²\(]{4})/gi, '$1\{\{convert|$2$3$4|sqmi|km2|\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}00),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)miles([^²\(]{2})/gi, '$1\{\{convert|$2$3$4|sqmi|km2|\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}0),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)miles([^²\(]{2})/gi, '$1\{\{convert|$2$3$4|sqmi|km2|\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)miles([^²\(]{2})/gi, '$1\{\{convert|$2$3$4|sqmi|km2|\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)miles([^²\(]{2})/gi, '$1\{\{convert|$2$3$4|sqmi|km2|\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)miles([^²\(]{2})/gi, '$1\{\{convert|$2$3$4|sqmi|km2|\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)miles([^²\(]{2})/gi, '$1\{\{convert|$2$3$4|sqmi|km2|\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)miles([^²\(]{2})/gi, '$1\{\{convert|$2$3$4$5|sqmi|km2|\}\}$6');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d\d)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)miles([^²\(]{2})/gi, '$1\{\{convert|$2$3$4$5|sqmi|km2|\}\}$6');
    // square mile:singular
txt.value=txt.value.replace(/(\s)(\d{1,3}),?(000),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)miles?([^s²\(]{2})/gi, '$1\{\{convert|$2$3$4|sqmi|km2|\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}00),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)miles?([^s²\(]{2})/gi, '$1\{\{convert|$2$3$4|sqmi|km2|\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}0),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)miles?([^s²\(]{2})/gi, '$1\{\{convert|$2$3$4|sqmi|km2|\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)miles?([^s²\(]{2})/gi, '$1\{\{convert|$2$3$4|sqmi|km2|\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)miles?([^s²\(]{2})/gi, '$1\{\{convert|$2$3$4|sqmi|km2|\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)miles?([^s²\(]{2})/gi, '$1\{\{convert|$2$3$4|sqmi|km2|\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)miles?([^s²\(]{2})/gi, '$1\{\{convert|$2$3$4|sqmi|km2|\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)miles?([^s²\(]{2})/gi, '$1\{\{convert|$2$3$4$5|sqmi|km2|\}\}$6');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d\d)(?:\s|-|&nbsp;)square(?:\s|-|&nbsp;)miles?([^s²\(]{2})/gi, '$1\{\{convert|$2$3$4$5|sqmi|km2|\}\}$6');
    // square mile:abbreviated
txt.value=txt.value.replace(/(\s)(\d{1,3}),?(000),?(000)(?:\s|-|&nbsp;)sq(?:\s|-|&nbsp;)mi([^l²\(]{2})/gi, '$1\{\{convert|$2$3$4|sqmi|km2|abbr=on\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}00),?(000)(?:\s|-|&nbsp;)sq(?:\s|-|&nbsp;)mi([^l²\(]{2})/gi, '$1\{\{convert|$2$3$4|sqmi|km2|abbr=on\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}0),?(000)(?:\s|-|&nbsp;)sq(?:\s|-|&nbsp;)mi([^l²\(]{2})/gi, '$1\{\{convert|$2$3$4|sqmi|km2|abbr=on\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)sq(?:\s|-|&nbsp;)mi([^l²\(]{2})/gi, '$1\{\{convert|$2$3$4|sqmi|km2|abbr=on\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}00)(?:\s|-|&nbsp;)sq(?:\s|-|&nbsp;)mi([^l²\(]{2})/gi, '$1\{\{convert|$2$3$4|sqmi|km2|abbr=on\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}0)(?:\s|-|&nbsp;)sq(?:\s|-|&nbsp;)mi([^l²\(]{2})/gi, '$1\{\{convert|$2$3$4|sqmi|km2|abbr=on\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)sq(?:\s|-|&nbsp;)mi([^l²\(]{2})/gi, '$1\{\{convert|$2$3$4|sqmi|km2|abbr=on\}\}$5');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d)(?:\s|-|&nbsp;)sq(?:\s|-|&nbsp;)mi([^l²\(]{2})/gi, '$1\{\{convert|$2$3$4$5|sqmi|km2|abbr=on\}\}$6');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(\.\d\d)(?:\s|-|&nbsp;)sq(?:\s|-|&nbsp;)mi([^l²\(]{2})/gi, '$1\{\{convert|$2$3$4$5|sqmi|km2|abbr=on\}\}$6');
 
    //nautical mile
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3}00),?(000)(?:\s|-|&nbsp;)mi([^l²\(\)]{2})al(?:\s|-|&nbsp;)miles?([^p\(\)]{2})/gi, '$1\{\{convert|$2$3|nmi|km mi|\}\}$4');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3}00),?(000)(?:\s|-|&nbsp;)mi([^l²\(\)]{2})al(?:\s|-|&nbsp;)mi(\s[^p\(\)]{2})/gi, '$1\{\{convert|$2$3|nmi|km mi|abbr=on\}\}$4');
 
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3}0),?(000)(?:\s|-|&nbsp;)mi([^l²\(\)]{2})al(?:\s|-|&nbsp;)miles?([^p\(\)]{2})/gi, '$1\{\{convert|$2$3|nmi|km mi|\}\}$4');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3}0),?(000)(?:\s|-|&nbsp;)mi([^l²\(\)]{2})al(?:\s|-|&nbsp;)mi(\s[^p\(\)]{2})/gi, '$1\{\{convert|$2$3|nmi|km mi|abbr=on\}\}$4');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3}),?(000)(?:\s|-|&nbsp;)mi([^l²\(\)]{2})al(?:\s|-|&nbsp;)miles?([^p\(\)]{2})/gi, '$1\{\{convert|$2$3|nmi|km mi|\}\}$4');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3}),?(000)(?:\s|-|&nbsp;)mi([^l²\(\)]{2})al(?:\s|-|&nbsp;)mi(\s[^p\(\)]{2})/gi, '$1\{\{convert|$2$3|nmi|km mi|abbr=on\}\}$4');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3}),?(\d{1,3}00)(?:\s|-|&nbsp;)mi([^l²\(\)]{2})al(?:\s|-|&nbsp;)miles?([^p\(\)]{2})/gi, '$1\{\{convert|$2$3|nmi|km mi|\}\}$4');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3}),?(\d{1,3}00)(?:\s|-|&nbsp;)mi([^l²\(\)]{2})al(?:\s|-|&nbsp;)mi(\s[^p\(\)]{2})/gi, '$1\{\{convert|$2$3|nmi|km mi|abbr=on\}\}$4');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3}),?(\d{1,3}0)(?:\s|-|&nbsp;)mi([^l²\(\)]{2})al(?:\s|-|&nbsp;)miles?([^p\(\)]{2})/gi, '$1\{\{convert|$2$3|nmi|km mi|\}\}$4');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3}),?(\d{1,3}0)(?:\s|-|&nbsp;)mi([^l²\(\)]{2})al(?:\s|-|&nbsp;)mi(\s[^p\(\)]{2})/gi, '$1\{\{convert|$2$3|nmi|km mi|abbr=on\}\}$4');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3}),?(\d{1,3})(?:\s|-|&nbsp;)mi([^l²\(\)]{2})al(?:\s|-|&nbsp;)miles?([^p\(\)]{2})/gi, '$1\{\{convert|$2$3|nmi|km mi|\}\}$4');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3}),?(\d{1,3})(?:\s|-|&nbsp;)mi([^l²\(\)]{2})al(?:\s|-|&nbsp;)mi(\s[^p\(\)]{2})/gi, '$1\{\{convert|$2$3|nmi|km mi|abbr=on\}\}$4');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3}000)(?:\s|-|&nbsp;)mi([^l²\(\)]{2})al(?:\s|-|&nbsp;)miles?([^p\(\)]{2})/gi, '$1\{\{convert|$2|nmi|km mi|\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3}000)(?:\s|-|&nbsp;)mi([^l²\(\)]{2})al(?:\s|-|&nbsp;)mi(\s[^p\(\)]{2})/gi, '$1\{\{convert|$2|nmi|km mi|abbr=on\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3}00)(?:\s|-|&nbsp;)mi([^l²\(\)]{2})al(?:\s|-|&nbsp;)miles?([^p\(\)]{2})/gi, '$1\{\{convert|$2|nmi|km mi|\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3}00)(?:\s|-|&nbsp;)mi([^l²\(\)]{2})al(?:\s|-|&nbsp;)mi(\s[^p\(\)]{2})/gi, '$1\{\{convert|$2|nmi|km mi|abbr=on\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3}0)(?:\s|-|&nbsp;)mi([^l²\(\)]{2})al(?:\s|-|&nbsp;)miles?([^p\(\)]{2})/gi, '$1\{\{convert|$2|nmi|km mi|\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3}0)(?:\s|-|&nbsp;)mi([^l²\(\)]{2})al(?:\s|-|&nbsp;)mi(\s[^p\(\)]{2})/gi, '$1\{\{convert|$2|nmi|km mi|abbr=on\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})(?:\s|-|&nbsp;)mi([^l²\(\)]{2})al(?:\s|-|&nbsp;)miles?([^p\(\)]{2})/gi, '$1\{\{convert|$2|nmi|km mi|\}\}$3');
txt.value=txt.value.replace(/([^\d,\.])(\d{1,3})(?:\s|-|&nbsp;)mi([^l²\(\)]{2})al(?:\s|-|&nbsp;)mi(\s[^p\(\)]{2})/gi, '$1\{\{convert|$2|nmi|km mi|abbr=on\}\}$3');
 
 
    //acre
//acres - temporary change to protect acre feet. changed below
txt.value=txt.value.replace(/(acre.feet)/gi, 'xtempx$1ytempy');
 
txt.value=txt.value.replace(/\[\[(acres?)\]\]/gi, '$1');
txt.value=txt.value.replace(/(\d)-(acre)/gi, '$1 $2');
txt.value=txt.value.replace(/(\d)(?:\s|-|&nbsp;)surface(?:\s|-|&nbsp;)(acre)/gi, '$1 $2');
txt.value=txt.value.replace(/(\s250(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (1 km²)$2');
txt.value=txt.value.replace(/(\s500(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (2 km²)$2');
txt.value=txt.value.replace(/(\s750(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (3 km²)$2');
txt.value=txt.value.replace(/(\s1(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (4 km²)$2');
txt.value=txt.value.replace(/(\s1,?500(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (6 km²)$2');
txt.value=txt.value.replace(/(\s2(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (8 km²)$2');
txt.value=txt.value.replace(/(\s2,?500(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (10 km²)$2');
txt.value=txt.value.replace(/(\s3(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (12 km²)$2');
txt.value=txt.value.replace(/(\s4(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (16 km²)$2');
txt.value=txt.value.replace(/(\s5(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (20 km²)$2');
txt.value=txt.value.replace(/(\s6(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (24 km²)$2');
txt.value=txt.value.replace(/(\s7(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (28 km²)$2');
txt.value=txt.value.replace(/(\s8(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (32 km²)$2');
txt.value=txt.value.replace(/(\s9(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (36 km²)$2');
txt.value=txt.value.replace(/(\s10(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (40 km²)$2');
txt.value=txt.value.replace(/(\s11(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (44 km²)$2');
txt.value=txt.value.replace(/(\s12(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (49 km²)$2');
txt.value=txt.value.replace(/(\s13(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (53 km²)$2');
txt.value=txt.value.replace(/(\s14(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (57 km²)$2');
txt.value=txt.value.replace(/(\s15(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (61 km²)$2');
txt.value=txt.value.replace(/(\s16(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (65 km²)$2');
txt.value=txt.value.replace(/(\s17(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (69 km²)$2');
txt.value=txt.value.replace(/(\s18(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (73 km²)$2');
txt.value=txt.value.replace(/(\s19(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (77 km²)$2');
txt.value=txt.value.replace(/(\s20(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (80 km²)$2');
txt.value=txt.value.replace(/(\s30(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (120 km²)$2');
txt.value=txt.value.replace(/(\s40(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (160 km²)$2');
txt.value=txt.value.replace(/(\s50(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (200 km²)$2');
txt.value=txt.value.replace(/(\s60(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (240 km²)$2');
txt.value=txt.value.replace(/(\s70(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (280 km²)$2');
txt.value=txt.value.replace(/(\s80(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (320 km²)$2');
txt.value=txt.value.replace(/(\s90(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (360 km²)$2');
txt.value=txt.value.replace(/(\s100(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (400 km²)$2');
txt.value=txt.value.replace(/(\s110(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (440 km²)$2');
txt.value=txt.value.replace(/(\s120(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (490 km²)$2');
txt.value=txt.value.replace(/(\s130(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (530 km²)$2');
txt.value=txt.value.replace(/(\s140(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (570 km²)$2');
txt.value=txt.value.replace(/(\s150(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (610 km²)$2');
txt.value=txt.value.replace(/(\s160(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (650 km²)$2');
txt.value=txt.value.replace(/(\s170(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (690 km²)$2');
txt.value=txt.value.replace(/(\s180(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (730 km²)$2');
txt.value=txt.value.replace(/(\s190(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (770 km²)$2');
txt.value=txt.value.replace(/(\s200(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (800 km²)$2');
txt.value=txt.value.replace(/(\s300(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (1,200 km²)$2');
txt.value=txt.value.replace(/(\s400(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (1,600 km²)$2');
txt.value=txt.value.replace(/(\s500(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (2,000 km²)$2');
txt.value=txt.value.replace(/(\s600(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (2,400 km²)$2');
txt.value=txt.value.replace(/(\s700(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (2,800 km²)$2');
txt.value=txt.value.replace(/(\s800(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (3,200 km²)$2');
txt.value=txt.value.replace(/(\s900(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (3,600 km²)$2');
txt.value=txt.value.replace(/([^y]\sone(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (4 km²)$2');
txt.value=txt.value.replace(/(\sa(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (4 km²)$2');
txt.value=txt.value.replace(/([^y]\stwo(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (8 km²)$2');
txt.value=txt.value.replace(/([^y]\sthree(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (12 km²)$2');
txt.value=txt.value.replace(/([^y]\sfour(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (16 km²)$2');
txt.value=txt.value.replace(/([^y]\sfive(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (20 km²)$2');
txt.value=txt.value.replace(/([^y]\ssix(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (24 km²)$2');
txt.value=txt.value.replace(/([^y]\sseven(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (28 km²)$2');
txt.value=txt.value.replace(/([^y]\seight(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (32 km²)$2');
txt.value=txt.value.replace(/([^y]\snine(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (36 km²)$2');
txt.value=txt.value.replace(/([^y]\sten(?:\s|-|&nbsp;)thousand(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (40 km²)$2');
txt.value=txt.value.replace(/(\s1(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (4,000 km²)$2');
txt.value=txt.value.replace(/(\s1,?500(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (6,000 km²)$2');
txt.value=txt.value.replace(/(\s2(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (8,000 km²)$2');
txt.value=txt.value.replace(/(\s2,?500(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (10,000 km²)$2');
txt.value=txt.value.replace(/(\s3(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (12,000 km²)$2');
txt.value=txt.value.replace(/(\s4(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (16,000 km²)$2');
txt.value=txt.value.replace(/(\s5(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (20,000 km²)$2');
txt.value=txt.value.replace(/(\s6(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (24,000 km²)$2');
txt.value=txt.value.replace(/(\s7(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (28,000 km²)$2');
txt.value=txt.value.replace(/(\s8(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (32,000 km²)$2');
txt.value=txt.value.replace(/(\s9(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (36,000 km²)$2');
txt.value=txt.value.replace(/(\s10(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (40,000 km²)$2');
txt.value=txt.value.replace(/(\s11(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (44,000 km²)$2');
txt.value=txt.value.replace(/(\s12(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (49,000 km²)$2');
txt.value=txt.value.replace(/(\s13(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (53,000 km²)$2');
txt.value=txt.value.replace(/(\s14(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (57,000 km²)$2');
txt.value=txt.value.replace(/(\s15(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (61,000 km²)$2');
txt.value=txt.value.replace(/(\s16(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (65,000 km²)$2');
txt.value=txt.value.replace(/(\s17(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (69,000 km²)$2');
txt.value=txt.value.replace(/(\s18(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (73,000 km²)$2');
txt.value=txt.value.replace(/(\s19(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (77,000 km²)$2');
txt.value=txt.value.replace(/(\s20(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (80,000 km²)$2');
txt.value=txt.value.replace(/(\s30(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (120,000 km²)$2');
txt.value=txt.value.replace(/(\s40(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (160,000 km²)$2');
txt.value=txt.value.replace(/(\s50(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (200,000 km²)$2');
txt.value=txt.value.replace(/(\s60(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (240,000 km²)$2');
txt.value=txt.value.replace(/(\s70(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (280,000 km²)$2');
txt.value=txt.value.replace(/(\s80(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (320,000 km²)$2');
txt.value=txt.value.replace(/(\s90(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (360,000 km²)$2');
txt.value=txt.value.replace(/(\s100(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (400,000 km²)$2');
txt.value=txt.value.replace(/(\s110(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (440,000 km²)$2');
txt.value=txt.value.replace(/(\s120(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (490,000 km²)$2');
txt.value=txt.value.replace(/(\s130(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (530,000 km²)$2');
txt.value=txt.value.replace(/(\s140(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (570,000 km²)$2');
txt.value=txt.value.replace(/(\s150(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (610,000 km²)$2');
txt.value=txt.value.replace(/(\s160(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (650,000 km²)$2');
txt.value=txt.value.replace(/(\s170(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (690,000 km²)$2');
txt.value=txt.value.replace(/(\s180(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (730,000 km²)$2');
txt.value=txt.value.replace(/(\s190(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (770,000 km²)$2');
txt.value=txt.value.replace(/(\s200(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (800,000 km²)$2');
txt.value=txt.value.replace(/(\s300(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (1,200,000 km²)$2');
txt.value=txt.value.replace(/(\s400(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (1,600,000 km²)$2');
txt.value=txt.value.replace(/(\s500(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (2,000,000 km²)$2');
txt.value=txt.value.replace(/(\s600(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (2,400,000 km²)$2');
txt.value=txt.value.replace(/(\s700(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (2,800,000 km²)$2');
txt.value=txt.value.replace(/(\s800(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (3,200,000 km²)$2');
txt.value=txt.value.replace(/(\s900(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (3,600,000 km²)$2');
txt.value=txt.value.replace(/([^y]\sone(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (4,000 km²)$2');
txt.value=txt.value.replace(/(\sa(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (4,000 km²)$2');
txt.value=txt.value.replace(/([^y]\stwo(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (8,000 km²)$2');
txt.value=txt.value.replace(/([^y]\sthree(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (12,000 km²)$2');
txt.value=txt.value.replace(/([^y]\sfour(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (16,000 km²)$2');
txt.value=txt.value.replace(/([^y]\sfive(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (20,000 km²)$2');
txt.value=txt.value.replace(/([^y]\ssix(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (24,000 km²)$2');
txt.value=txt.value.replace(/([^y]\sseven(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (28,000 km²)$2');
txt.value=txt.value.replace(/([^y]\seight(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (32,000 km²)$2');
txt.value=txt.value.replace(/([^y]\snine(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (36,000 km²)$2');
txt.value=txt.value.replace(/([^y]\sten(?:\s|-|&nbsp;)million(?:\s|-|&nbsp;)acres?)([^\(]{4})/gi, '$1 (40,000 km²)$2');

//acre:plural

txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)(\s[^\(\/])/gi, '$1\{\{convert|$2$3$4|acre|ha|\}\}$5');

txt.value=txt.value.replace(/(\s)(\d{3})(?:\s|-|&nbsp;)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^\(]{2})/gi, '$1\{\{convert|$2|acre|ha|\}\}$3');
 
txt.value=txt.value.replace(/(\s)(\d{1,3}),?(000),?(000),?(000)(?:\s|-|&nbsp;)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^\(]{2})/gi, '$1\{\{convert|$2$3$4$5|acre|ha|\}\}$6');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}00),?(000),?(000)(?:\s|-|&nbsp;)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^\(]{2})/gi, '$1\{\{convert|$2$3$4$5|acre|ha|\}\}$6');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}0),?(000),?(000)(?:\s|-|&nbsp;)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^\(]{2})/gi, '$1\{\{convert|$2$3$4$5|acre|ha|\}\}$6');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}),?(000),?(000)(?:\s|-|&nbsp;)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^\(]{2})/gi, '$1\{\{convert|$2$3$4$5|acre|ha|\}\}$6');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}00),?(000)(?:\s|-|&nbsp;)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^\(]{2})/gi, '$1\{\{convert|$2$3$4$5|acre|ha|\}\}$6');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}0),?(000)(?:\s|-|&nbsp;)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^\(]{2})/gi, '$1\{\{convert|$2$3$4$5|acre|ha|\}\}$6');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^\(]{2})/gi, '$1\{\{convert|$2$3$4$5|acre|ha|\}\}$6');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})?,?(\d{1}00)(?:\s|-|&nbsp;)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^\(]{2})/gi, '$1\{\{convert|$2$3$4$5|acre|ha|\}\}$6');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})?,?(\d{2}0)(?:\s|-|&nbsp;)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^\(]{2})/gi, '$1\{\{convert|$2$3$4$5|acre|ha|\}\}$6');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})?,?(\d{3})(?:\s|-|&nbsp;)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([^\(]{2})/gi, '$1\{\{convert|$2$3$4$5|acre|ha|\}\}$6');
//acre:singular

txt.value=txt.value.replace(/([^\/]\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-|&nbsp;)(?:acre|\[\[acre\]\])(\s[^\(\/])/gi, '$1\{\{convert|$2$3$4|acre|ha|sing=on\}\}$5');

txt.value=txt.value.replace(/(\s)(\d{3})(?:\s|-|&nbsp;)(?:acre|\[\[acre\]\])([^s\(][^\(])/gi, '$1\{\{convert|$2|acre|ha|sing=on\}\}$3');
 
txt.value=txt.value.replace(/(\s)(\d{3})(\.\d)?(?:\s|-|&nbsp;)(?:acre|\[\[acre\]\])([^s\(][^\(])/gi, '$1\{\{convert|$2$3|acre|ha|sing=on\}\}$4');
txt.value=txt.value.replace(/(\s)(\d{1,3}),?(000),?(000),?(000)(?:\s|-|&nbsp;)(?:acre|\[\[acre\]\])([^s\(][^\(])/gi, '$1\{\{convert|$2$3$4$5|acre|ha|sing=on\}\}$6');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}00),?(000),?(000)(?:\s|-|&nbsp;)(?:acre|\[\[acre\]\])([^s\(][^\(])/gi, '$1\{\{convert|$2$3$4$5|acre|ha|sing=on\}\}$6');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}0),?(000),?(000)(?:\s|-|&nbsp;)(?:acre|\[\[acre\]\])([^s\(][^\(])/gi, '$1\{\{convert|$2$3$4$5|acre|ha|sing=on\}\}$6');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3}),?(000),?(000)(?:\s|-|&nbsp;)(?:acre|\[\[acre\]\])([^s\(][^\(])/gi, '$1\{\{convert|$2$3$4$5|acre|ha|sing=on\}\}$6');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}00),?(000)(?:\s|-|&nbsp;)(?:acre|\[\[acre\]\])([^s\(][^\(])/gi, '$1\{\{convert|$2$3$4$5|acre|ha|sing=on\}\}$6');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}0),?(000)(?:\s|-|&nbsp;)(?:acre|\[\[acre\]\])([^s\(][^\(])/gi, '$1\{\{convert|$2$3$4$5|acre|ha|sing=on\}\}$6');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}),?(000)(?:\s|-|&nbsp;)(?:acre|\[\[acre\]\])([^s\(][^\(])/gi, '$1\{\{convert|$2$3$4$5|acre|ha|sing=on\}\}$6');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})?,?(\d{1}00)(?:\s|-|&nbsp;)(?:acre|\[\[acre\]\])([^s\(][^\(])/gi, '$1\{\{convert|$2$3$4$5|acre|ha|sing=on\}\}$6');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})?,?(\d{2}0)(?:\s|-|&nbsp;)(?:acre|\[\[acre\]\])([^s\(][^\(])/gi, '$1\{\{convert|$2$3$4$5|acre|ha|sing=on\}\}$6');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})?,?(\d{3})(?:\s|-|&nbsp;)(?:acre|\[\[acre\]\])([^s\(][^\(])/gi, '$1\{\{convert|$2$3$4$5|acre|ha|sing=on\}\}$6');
 


 
 
//undo protection for acre feet
txt.value=txt.value.replace(/xtempx(acre.feet)ytempy/gi, '$1');
 
    // foot pound
txt.value=txt.value.replace(/ftlbs?(\W)/gi, 'ft•lbf$1');
txt.value=txt.value.replace(/ft[ -.••\/]lb(\W)/gi, 'ft•lbf$1');
txt.value=txt.value.replace(/ft[ -.••\/]lbs/gi, 'ft•lbf');
txt.value=txt.value.replace(/ft[ -.••\/]lbf/gi, 'ft•lbf');
txt.value=txt.value.replace(/ft[ -.••\/]lbff/gi, 'ft•lbf');
 
//foot (again). Parsed after 'foot per second' and 'foot pound'
txt.value=txt.value.replace(/\[\[(feet)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[Foot\s\(unit\sof\slength\)\|(feet:foot|ft)\]\]/gi, '$1');
txt.value=txt.value.replace(/(\d)-(feet)/gi, '$1 $2');
//feet: plural
txt.value=txt.value.replace(/([^\dr]\s)(\d{1,3})?[\s,]?(000)[\s,]?(000)(?:\s|-|&nbsp;)feet([^\w\(\)][^o\d\(\)])/gi, '$1\{\{convert|$2$3$4|ft|m|\}\}$5');
txt.value=txt.value.replace(/([^\dr]\s)(\d{1,3})?[\s,]?(\d{1,3}00)[\s,]?(000)(?:\s|-|&nbsp;)feet([^\w\(\)][^o\d\(\)])/gi, '$1\{\{convert|$2$3$4|ft|m|\}\}$5');
txt.value=txt.value.replace(/([^\dr]\s)(\d{1,3})?[\s,]?(\d{1,3}0)[\s,]?(000)(?:\s|-|&nbsp;)feet([^\w\(\)][^o\d\(\)])/gi, '$1\{\{convert|$2$3$4|ft|m|\}\}$5');
txt.value=txt.value.replace(/([^\dr]\s)(\d{1,3})?[\s,]?(\d{1,3})[\s,]?(000)(?:\s|-|&nbsp;)feet([^\w\(\)][^o\d\(\)])/gi, '$1\{\{convert|$2$3$4|ft|m|\}\}$5');
txt.value=txt.value.replace(/([^\dr]\s)(\d{1,3})?[\s,]?(\d{1,3})?[\s,]?(\d{1,3}00)(?:\s|-|&nbsp;)feet([^\w\(\)][^o\d\(\)])/gi, '$1\{\{convert|$2$3$4|ft|m|\}\}$5');
txt.value=txt.value.replace(/([^\dr]\s)(\d{1,3})?[\s,]?(\d{1,3})?[\s,]?(\d{1,3}0)(?:\s|-|&nbsp;)feet([^\w\(\)][^o\d\(\)])/gi, '$1\{\{convert|$2$3$4|ft|m|\}\}$5');
txt.value=txt.value.replace(/([^\dr]\s)(\d{1,3})?[\s,]?(\d{1,3})?[\s,]?(\d{1,3})(?:\s|-|&nbsp;)feet([^\w\(\)][^o\d\(\)])/gi, '$1\{\{convert|$2$3$4|ft|m|\}\}$5');
txt.value=txt.value.replace(/([^\dr]\s)(\d{1,3})?[\s,]?(\d{1,3})?[\s,]?(\d{1,3})(\.\d)(?:\s|-|&nbsp;)feet([^\w\(\)][^o\d\(\)])/gi, '$1\{\{convert|$2$3$4$5|ft|m|\}\}$6');
txt.value=txt.value.replace(/([^\dr]\s)(\d{1,3})?[\s,]?(\d{1,3})?[\s,]?(\d{1,3})(\.\d\d)(?:\s|-|&nbsp;)feet([^\w\(\)][^o\d\(\)])/gi, '$1\{\{convert|$2$3$4$5|ft|m|\}\}$6');
//feet: singular
txt.value=txt.value.replace(/([^\dr]\s)(\d{1,3})?[\s,]?(000)[\s,]?(000)(?:\s|-|&nbsp;)foot([^\aip\(\)]{2})/gi, '$1\{\{convert|$2$3$4|ft|m|sing=on\}\}$5');
txt.value=txt.value.replace(/([^\dr]\s)(\d{1,3})?[\s,]?(\d{1,3}00)[\s,]?(000)(?:\s|-|&nbsp;)foot([^•\w\(\)][^o\d\(\)])/gi, '$1\{\{convert|$2$3$4|ft|m|sing=on\}\}$5');
txt.value=txt.value.replace(/([^\dr]\s)(\d{1,3})?[\s,]?(\d{1,3}0)[\s,]?(000)(?:\s|-|&nbsp;)foot([^•\w\(\)][^o\d\(\)])/gi, '$1\{\{convert|$2$3$4|ft|m|sing=on\}\}$5');
txt.value=txt.value.replace(/([^\dr]\s)(\d{1,3})?[\s,]?(\d{1,3})[\s,]?(000)(?:\s|-|&nbsp;)foot([^•\w\(\)][^o\d\(\)])/gi, '$1\{\{convert|$2$3$4|ft|m|sing=on\}\}$5');
txt.value=txt.value.replace(/([^\dr]\s)(\d{1,3})?[\s,]?(\d{1,3})?[\s,]?(\d{1,3}00)(?:\s|-|&nbsp;)foot([^•\w\(\)][^o\d\(\)])/gi, '$1\{\{convert|$2$3$4|ft|m|sing=on\}\}$5');
txt.value=txt.value.replace(/([^\dr]\s)(\d{1,3})?[\s,]?(\d{1,3})?[\s,]?(\d{1,3}0)(?:\s|-|&nbsp;)foot([^•\w\(\)][^o\d\(\)])/gi, '$1\{\{convert|$2$3$4|ft|m|sing=on\}\}$5');
txt.value=txt.value.replace(/([^\dr]\s)(\d{1,3})?[\s,]?(\d{1,3})?[\s,]?(\d{1,3})(?:\s|-|&nbsp;)foot([^•\w\(\)][^o\d\(\)])/gi, '$1\{\{convert|$2$3$4|ft|m|sing=on\}\}$5');
txt.value=txt.value.replace(/([^\dr]\s)(\d{1,3})?[\s,]?(\d{1,3})?[\s,]?(\d{1,3})(\.\d)(?:\s|-|&nbsp;)foot([^•\w\(\)][^o\d\(\)])/gi, '$1\{\{convert|$2$3$4$5|ft|m|sing=on\}\}$6');
txt.value=txt.value.replace(/([^\dr]\s)(\d{1,3})?[\s,]?(\d{1,3})?[\s,]?(\d{1,3})(\.\d\d)(?:\s|-|&nbsp;)foot([^•\w\(\)][^o\d\(\)])/gi, '$1\{\{convert|$2$3$4$5|ft|m|sing=on\}\}$6');
//feet: abbreviated
txt.value=txt.value.replace(/([^\dr]\s)(\d{1,3})?[\s,]?(000)[\s,]?(000)(?:\s|-|&nbsp;)ft([^\w\(\)\/][^lo\d\(\)][^\(])/gi, '$1\{\{convert|$2$3$4|ft|m|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^\dr]\s)(\d{1,3})?[\s,]?(\d{1,3}00)[\s,]?(000)(?:\s|-|&nbsp;)ft([^\w\(\)\/][^lo\d\(\)][^\(])/gi, '$1\{\{convert|$2$3$4|ft|m|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^\dr]\s)(\d{1,3})?[\s,]?(\d{1,3}0)[\s,]?(000)(?:\s|-|&nbsp;)ft([^\w\(\)\/][^lo\d\(\)][^\(])/gi, '$1\{\{convert|$2$3$4|ft|m|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^\dr]\s)(\d{1,3})?[\s,]?(\d{1,3})[\s,]?(000)(?:\s|-|&nbsp;)ft([^\w\(\)\/][^lo\d\(\)][^\(])/gi, '$1\{\{convert|$2$3$4|ft|m|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^\dr]\s)(\d{1,3})?[\s,]?(\d{1,3})?[\s,]?(\d{1,3}00)(?:\s|-|&nbsp;)ft([^\w\(\)\/][^lo\d\(\)][^\(])/gi, '$1\{\{convert|$2$3$4|ft|m|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^\dr]\s)(\d{1,3})?[\s,]?(\d{1,3})?[\s,]?(\d{1,3}0)(?:\s|-|&nbsp;)ft([^\w\(\)\/][^lo\d\(\)][^\(])/gi, '$1\{\{convert|$2$3$4|ft|m|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^\dr]\s)(\d{1,3})?[\s,]?(\d{1,3})?[\s,]?(\d{1,3})(?:\s|-|&nbsp;)ft([^\w\(\)\/][^lo\d\(\)][^\(])/gi, '$1\{\{convert|$2$3$4|ft|m|abbr=on\}\}$5');
txt.value=txt.value.replace(/([^\dr]\s)(\d{1,3})?[\s,]?(\d{1,3})?[\s,]?(\d{1,3})(\.\d)(?:\s|-|&nbsp;)ft([^\w\(\)\/][^lo\d\(\)][^\(])/gi, '$1\{\{convert|$2$3$4$5|ft|m|abbr=on\}\}$6');
txt.value=txt.value.replace(/([^\dr]\s)(\d{1,3})?[\s,]?(\d{1,3})?[\s,]?(\d{1,3})(\.\d\d)(?:\s|-|&nbsp;)ft([^\w\(\)\/][^lo\d\(\)][^\(])/gi, '$1\{\{convert|$2$3$4$5|ft|m|abbr=on\}\}$6');
 
 
 
 
    // horsepower
txt.value=txt.value.replace(/(\d)\s?hp(\W)/gi, '$1 hp$2');
txt.value=txt.value.replace(/(\d)&nbsp;hp(\W)/gi, '$1&nbsp;hp$2');
txt.value=txt.value.replace(/(\d)\s?bhp/gi, '$1 bhp');
txt.value=txt.value.replace(/(\d)&nbsp;bhp/gi, '$1&nbsp;bhp');
txt.value=txt.value.replace(/(\d)\s?shp/gi, '$1 shp');
txt.value=txt.value.replace(/(\d)&nbsp;shp/gi, '$1&nbsp;shp');
 
    //Pferdestärke
txt.value=txt.value.replace(/(\d)\s?(ps\W)/gi, '$1 $2');
 
    // rpm
txt.value=txt.value.replace(/(\d)\s?rpm/gi, '$1 rpm');
txt.value=txt.value.replace(/(\d)&nbsp;rpm/gi, '$1&nbsp;rpm');
txt.value=txt.value.replace(/(\d)\-rpm/gi, '$1 rpm');
 
    // decibel
txt.value=txt.value.replace(/(\d)\s?(dB)\b/g, '$1 $2');
 
    // bits per second
txt.value=txt.value.replace(/([KkMmGgTt])(bps|bits?\/s|b\/s)/g, '$1bit/s');
txt.value=txt.value.replace(/(\d)\s?bps/gi, '$1 bit/s');
txt.value=txt.value.replace(/(\d)&nbsp;bps/gi, '$1&nbsp;bit/s');
txt.value=txt.value.replace(/bits?\/sec(\W)/gi, 'bit/s$1');
 
    // bytes per second
txt.value=txt.value.replace(/([KkMmGgTt])(Bps|bytes?\/s)/g, ' $1byte/s');
txt.value=txt.value.replace(/bytes?\/s(\W)/gi, 'byte/s$1');
 
    // capitalization of prefix with bits and bytes
txt.value=txt.value.replace(/K(bit|B|byte)\/s/g, 'k$1/s');
txt.value=txt.value.replace(/m(bit|B|byte)\/s/g, 'M$1/s');
txt.value=txt.value.replace(/g(bit|B|byte)\/s/g, 'G$1/s');
txt.value=txt.value.replace(/t(bit|B|byte)\/s/g, 'T$1/s');
 
    // space with bits and bytes
txt.value=txt.value.replace(/([^\w]\d)\s?(k|M|G|T)(bit|B)/g, '$1 $2$3');
 
    //Remove surprise or 'Easter egg' diversions linking unit name to orders of magnitude articles
txt.value=txt.value.replace(/\[\[1\s?_?E\s?[\-\+]?\d{1,2}\s?..?\|([^\]]{1,50})\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[Orders\sof\smagnitude\s\([^\)]{1,30}\)\|([^\]]{1,50})\]\]/gi, '$1');
 
    //'present'
txt.value=txt.value.replace(/\[\[Present \(time\)\|(Present)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[(Present)\]\]/gi, '$1');
 
 
    //Season
txt.value=txt.value.replace(/\[\[(spring\s\(season\)|summer|winter|autumn)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[spring\s\(season\)\|(spring)\]\]/gi, '$1');
 
    //Identify surprise or 'Easter egg' diversions linking months to year articles.
txt.value=txt.value.replace(/\[\[\d{1,4}#[^\|]{1,30}\|(January|February|March|April|May|June|July|August|September|October|November|December)\]\]/gi, '$1');
 
    // months
txt.value=txt.value.replace(/\[\[\s?(January|February|March|April|May|June|July|August|September|October|November|December)\s?\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\|(January|February|March|April|May|June|July|August|September|October|November|December)\]\]/gi, '$1');
    //Treat 'Sept' (i.e. month abbreviation) differently from 'sept' (i.e. family)
txt.value=txt.value.replace(/\[\[(Sept)\]\]/g, '$1');
txt.value=txt.value.replace(/\[\[January\|(Jan)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[February\|(Feb)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[March\|(Mar)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[April\|(Apr)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[May\|(May)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[June\|(Jun)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[July\|(Jul)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[August\|(Aug)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[September\|(Sep)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[October\|(Oct)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[November\|(Nov)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[December\|(Dec)\]\]/gi, '$1');
 
    //month piped to number
txt.value=txt.value.replace(/\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\|(\d{1,4})\]\]/gi, '$1');
 
    //Month+day_number "March 7th" -> "March 7"
txt.value=txt.value.replace(/\[\[(January|February|March|April|May|June|July|August|September|October|November|December) (\d?\d)(?:th|st|nd|rd)\]\]/gi, '\[\[$1 $2\]\]');
txt.value=txt.value.replace(/\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December) \d?\d)\]\](?:th|st|nd|rd)/gi, '\[\[$1\]\]');
txt.value=txt.value.replace(/\[\[(\d?\d)(?:th|st|nd|rd) (January|February|March|April|May|June|July|August|September|October|November|December)\]\]/gi, '\[\[$1 $2\]\]');
 
    //Month+day_number piped into number. Preferences do not work. They don't work in sequence because digits in the two dates must be adjacent
txt.value=txt.value.replace(/([^\[]{4})\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December) \d?\d)\]\](\s?\-?\s?)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}\|(\d{1,2})\]\]/gi, '$1$2$3$4');
    //same again but with ndash or mdash instead of hyphen
txt.value=txt.value.replace(/([^\[]{4})\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December) \d?\d)\]\](\s?&[nm]dash;\s?)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}\|(\d{1,2})\]\]/gi, '$1$2$3$4');
    //same again but with slash instead of hyphen
txt.value=txt.value.replace(/([^\[]{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})\]\]/gi, '$1$2$3$4');
 
txt.value=txt.value.replace(/([^\[]{4})\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December) \d?\d)\]\](\s?\-?\s?)\[\[(\d{1,2})\]\]/gi, '$1$2$3$4');
    //same again but with ndash instead of hyphen
txt.value=txt.value.replace(/([^\[]{4})\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December) \d?\d)\]\](\s?&[nm]dash;\s?)\[\[(\d{1,2})\]\]/gi, '$1$2$3$4');
    //same again but with slash instead of hyphen
txt.value=txt.value.replace(/([^\[]{4})\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December) \d?\d)\]\](\/)\[\[(\d{1,2})\]\]/gi, '$1$2$3$4');
 
txt.value=txt.value.replace(/([^\[]{4})\[\[(\d?\d) (?:January|February|March|April|May|June|July|August|September|October|November|December)\]\](\s?\-?\s?)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}\|(\d{1,2})\]\]/gi, '$1$2$3$4');
    //same again but with ndash instead of hyphen
txt.value=txt.value.replace(/([^\[]{4})\[\[(\d?\d) (?:January|February|March|April|May|June|July|August|September|October|November|December)\]\](\s?&[nm]dash;\s?)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}\|(\d{1,2})\]\]/gi, '$1$2$3$4');
    //same again but with slash instead of hyphen
txt.value=txt.value.replace(/([^\[]{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})\]\]/gi, '$1$2$3$4');
 
txt.value=txt.value.replace(/([^\[]{4})\[\[(\d?\d) (?:January|February|March|April|May|June|July|August|September|October|November|December)\]\](\s?\-?\s?)\[\[(\d{1,2})\]\]/gi, '$1$2$3$4');
    //same again but with ndash instead of hyphen
txt.value=txt.value.replace(/([^\[]{4})\[\[(\d?\d) (?:January|February|March|April|May|June|July|August|September|October|November|December)\]\](\s?&[nm]dash;\s?)\[\[(\d{1,2})\]\]/gi, '$1$2$3$4');
    //same again but with slash instead of hyphen
txt.value=txt.value.replace(/([^\[]{4})\[\[(\d?\d) (?:January|February|March|April|May|June|July|August|September|October|November|December)\]\](\/)\[\[(\d{1,2})\]\]/gi, '$1$2$3$4');
 
txt.value=txt.value.replace(/\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}\|(\d{1,2})\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[\d{1,2} (?:January|February|March|April|May|June|July|August|September|October|November|December)\|(\d{1,2})\]\]/gi, '$1');
 
txt.value=txt.value.replace(/\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d{1,2}\|((?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{1,2})\]\]/gi, '$1');
    //month+day piped into month+day or vice versa
txt.value=txt.value.replace(/\[\[\d{1,2}\s(?:January|February|March|April|May|June|July|August|September|October|November|December)\|((?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d{1,2})\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d{1,2}\|(\d{1,2}\s(?:January|February|March|April|May|June|July|August|September|October|November|December))\]\]/gi, '$1');
 
 
    // days of the week in full. Optional plurals
txt.value=txt.value.replace(/\[\[(Mondays?|Tuesdays?|Wednesdays?|Thursdays?|Fridays?|Saturdays?|Sundays?)\]\]/gi, '$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'.
txt.value=txt.value.replace(/\[\[(Mon|Tue|Tues|Wed|Thu|Thur|Thurs|Fri)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[(Sat)\]\]/g, '$1');
txt.value=txt.value.replace(/\[\[Mondays?\|(Mondays?|Mon)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[Tuesdays?\|(Tuesdays?|Tues?)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[Wednesdays?\|(Wednesdays?|Wed)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[Thursdays?\|(Thursdays?|Thur?)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[Fridays?\|(Fridays?|Fri)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[Saturdays?\|(Saturdays?|Sat)\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[Sundays?\|(Sundays?|Sun)\]\]/gi, '$1');
 
    //4 digit years piped into 2
txt.value=txt.value.replace(/\[\[\d{1,4}\|(\d{1,2})\]\]/gi, '$1');
 
}
 
 
function run_dates() {
    var txt = document.editform.wpTextbox1;
    dates();
 
    // Add a tag to the summary box
    var txt = document.editform.wpSummary;
    var summary = "Dates";
	if (txt.value.indexOf(summary) == -1) {
		if (txt.value.match(/[^\*\/\s][^\/\s]?\s*$/)) {
			txt.value += " | ";
		}
		txt.value += summary;
	}
 
    // Press the diff button to check it
    document.editform.wpDiff.click()
}
$(function () {
    if(document.forms.editform && typeof addLink !== 'undefined') {
        addLink('p-cactions', 'javascript:run_dates()', 'dates', 'ca-unitfixer', 'Fixes some unit formatting', '', '');
    }
});
 
function run_formatgeneral() {
    var txt = document.editform.wpTextbox1;
    formatgeneral();
 
    // Add a tag to the summary box
    var txt = document.editform.wpSummary;
    var summary = "Format per [[wp:mosnum]]; units and/or dates using this [[User:MJCdetroit/monobook.js|Script]]";
	if (txt.value.indexOf(summary) == -1) {
		if (txt.value.match(/[^\*\/\s][^\/\s]?\s*$/)) {
			txt.value += " | ";
		}
		txt.value += summary;
	}
 
    // Press the diff button to check it
    document.editform.wpDiff.click()
}
$(function () {
    if(document.forms.editform && typeof addLink !== 'undefined') {
        addLink('p-cactions', 'javascript:run_formatgeneral()', 'Units', 'ca-unitfixer', 'Fixes some unit formatting', '', '');
    }
});
 
function combined() {
    var txt = document.editform.wpTextbox1;
    formatgeneral();
    dates();
 
    // Add a tag to the summary box
    var txt = document.editform.wpSummary;
    var summary = "Format per [[WP:MOSNUM]]; units and/or dates using this [[User:MJCdetroit/monobook.js|Script]]";
	if (txt.value.indexOf(summary) == -1) {
		if (txt.value.match(/[^\*\/\s][^\/\s]?\s*$/)) {
			txt.value += " | ";
		}
		txt.value += summary;
	}
 
    // Press the diff button to check it
    document.editform.wpDiff.click()
}
 
$(function () {
    if(document.forms.editform && typeof addLink !== 'undefined') {
        addLink('p-cactions', 'javascript:combined()', 'combined', 'ca-unitfixer', 'Fixes some unit formatting', '', '');
    }
});

// Script from [[User:ais523/editcount.js]]
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:ais523/editcount.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');