User:Lightmouse/monobook.js/script.js: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
Line 70:
txt.value=txt.value.replace(/xx(\d{1,4})xx/gi, '\[\[$1\]\]');
}
 
 
 
function formatgeneral() {
Line 97 ⟶ 99:
txt.value=txt.value.replace(/°/g, '°');
txt.value=txt.value.replace(/º/g, '°');
 
//aviation specifications: protect 'main=' and 'alt=' - undone below
txt.value=txt.value.replace(/((?:main|alt)\s?=\s?)(\d)/gi, '$1xx$2');
 
// Celsius spelling errors
Line 121 ⟶ 126:
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|-| |)°?F([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1{{convert|$2|°F|°C|abbr=on}}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(-?\d[\d,\.]{0,16})(?:\s|-| |)(?:deg|degree|degrees)(?:\s|-| |)Fahrenheit([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|°F|°C}}$3');
 
// Convert &sup to superscript
Line 130 ⟶ 135:
//metre
//delink this common unit
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-|)\[\[(metres|meters|metre|meter)\]\]([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1$2 $3$4');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-|)\[\[(metre|meter)\]\]s([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1$2 $3s$4');
//space before 'm' only when lower case. Check for dollars and pounds to avoid 'm' used for millions in money.
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-|)m([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1$2 m$3');
//convert 'metres' to 'm' when in parentheses
txt.value=txt.value.replace(/(\(\d[\d,\.]{0,16})(?:\s|-|)(?:metres|meters|metre|meter)(\))/g, '$1 m$2');
txt.value=txt.value.replace(/(\(\d[\d,\.]{0,16}) (?:metres|meters|metre|meter)(\))/g, '$1 m$2');
txt.value=txt.value.replace(/({convert\|\d{1,16}\|(?:m|ft)[^\}]{0,16})\|lk=(?:on|in|out)/g, '$1');
 
//metre per second
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-|)(?:m\/second|m\/sec)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1$2 m/s$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16}) (?:m\/second|m\/sec)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1$2 m/s$3');
txt.value=txt.value.replace(/({convert\|\d{1,16}\|(?:m\s|ft\s)[^\}]{0,16})\|lk=(?:on|in|out)/g, '$1');
 
//square metre
txt.value=txt.value.replace(/(\d)(?:\s|-| |)sq(?:\s|\.\s|-| )m([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 m²$2');
//remove period when followed by close parenthesis character
txt.value=txt.value.replace(/m²\.\)/gi, 'm²)');
txt.value=txt.value.replace(/({convert\|\d{1,16}\|(?:sqm|sqft)[^\}]{0,16})\|lk=(?:on|in|out)/g, '$1');
 
// millimetre
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-|)mm([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1$2 mm$3');
 
//Test
txt.value=txt.value.replace(/([^\d]\s)(\d{1,3})?,?(\d{1,3}00)(?:\s|-| )mm([^\(\)]{3})/gi, '$1{{Auto mm|$2$3|1}}$4');
txt.value=txt.value.replace(/([^\d]\s)(\d{1,3})?,?(\d{1,3}0)(?:\s|-| )mm([^\(\)]{3})/gi, '$1{{Auto mm|$2$3|1}}$4');
txt.value=txt.value.replace(/([^\d]\s)(\d{1,3})?,?(\d{1,3})(?:\s|-| )mm([^\(\)]{3})/gi, '$1{{Auto mm|$2$3|1}}$4');
txt.value=txt.value.replace(/([^\d]\s)(\d{1,3}\.\d\d)(?:\s|-| )mm([^\(\)]{3})/gi, '$1{{Auto mm|$2|1}}$3');
txt.value=txt.value.replace(/([^\d]\s)(\d{1,3}\.\d\d\d)(?:\s|-| )mm([^\(\)]{3})/gi, '$1{{Auto mm|$2|1}}$3');
 
 
// centimetre, cubic centimetre
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-|)(cm|cc)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1$2 $3$4');
 
// kilometre
//delink this common unit
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-|)\[\[(kilometres|kilometers|kilometre|kilometer)\]\]([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1$2 $3$4');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-|)\[\[(kilometre|kilometer)\]\]s([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1$2 $3s$4');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16}) \[\[(kilometres|kilometers|kilometre|kilometer)\]\]([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1$2 $3$4');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16}) \[\[(kilometre|kilometer)\]\]s([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1$2 $3s$4');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-|)kms?([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1$2 km$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16}) kms?([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1$2 km$3');
txt.value=txt.value.replace(/({convert\|\d{1,16}\|(?:mi|km)[^\}]{0,16})\|lk=(?:on|in|out)/g, '$1');
 
//square kilometre
txt.value=txt.value.replace(/(\d)(\s|-| )\[\[km²\]\]/gi, '$1$2km²');
txt.value=txt.value.replace(/(\d)\s?sq\.?(?:\s|-| |)kms?(\s|\.)/gi, '$1 km²$2');
txt.value=txt.value.replace(/({convert\|\d{1,16})00\|ha/g, '$1|sqkm');
txt.value=txt.value.replace(/({convert\|\d{1,16})(\d)0\|ha/g, '$1.$2|sqkm');
Line 183 ⟶ 178:
txt.value=txt.value.replace(/({convert\|\d{1,16}\|(?:sqkm|sqmi)[^\}]{0,16})\|lk=(?:on|in|out)/g, '$1');
txt.value=txt.value.replace(/({convert\|\d{3,16}\|acre\|)ha/g, '$1sqkm');
 
// test
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');
txt.value=txt.value.replace(/(\d)(?:\s|-|)PS(\W)/gi, '$1 PS$2');
txt.value=txt.value.replace(/(\d) PS(\W)/gi, '$1 PS$2');
txt.value=txt.value.replace(/(\d)(?:\s|-|)kg(\W)/gi, '$1 kg$2');
txt.value=txt.value.replace(/(\d) kg(\W)/gi, '$1 kg$2');
txt.value=txt.value.replace(/(\d)(?:\s|-|)lb(\W)/gi, '$1 lb$2');
txt.value=txt.value.replace(/(\d) lb(\W)/gi, '$1 lb$2');
 
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(000)(?:\s|-| )(lb|kW|PS|kg)([^\(\)]{2})/gi, '$1{{Auto $5|$2$3$4|0}}$6');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}00)(?:\s|-| )(lb|kW|PS|kg)([^\(\)]{2})/gi, '$1{{Auto $5|$2$3$4|0}}$6');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3}0)(?:\s|-| )(lb|kW|PS|kg)([^\(\)]{2})/gi, '$1{{Auto $5|$2$3$4|0}}$6');
txt.value=txt.value.replace(/(\s)(\d{1,3})?,?(\d{1,3})?,?(\d{1,3})(?:\s|-| )(lb|kW|PS|kg)([^\(\)]{2})/gi, '$1{{Auto $5|$2$3$4|0}}$6');
 
 
 
//kilometre per second
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-|)(?:km\/second|km\/sec)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1$2 km/s$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16}) (?:km\/second|km\/sec)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1$2 km/s$3');
 
// kilometre per hour
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-|)(?:km\/hr|km\/ph|kph|kmph|kmh)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1$2 km/h$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16}) (?:km\/hr|km\/ph|kph|kmph|kmh)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1$2 km/h$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-|)\[\[(?:km\/hr|km\/ph|kph|kmph|kmh)\]\]([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1$2 km/h$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16}) \[\[(?:km\/hr|km\/ph|kph|kmph|kmh)\]\]([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1$2 km/h$3');
 
//millilitre
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-|)(ml)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1$2 $3$4');
 
// ensure spaces and correct case in kilowatt
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-|)kW([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1$2 kW$3');
 
// ensure spaces and correct case in hertz
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-|)Hz([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1$2 Hz$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-|)kHz([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1$2 kHz$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-|)GHz([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1$2 GHz$3');
// ensure spaces in megahertz. Must be upper case to avoid clashing with millihertz
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-|)MHz([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1$2 MHz$3');
 
// frames per second
Line 231 ⟶ 208:
txt.value=txt.value.replace(/kilogrammes/gi, 'kilograms');
txt.value=txt.value.replace(/kilogramme/gi, 'kilogram');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-|)\[\[(kilograms?)\]\]([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1$2 $3$4');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16}) \[\[(kilograms?)\]\]([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1$2 $3$4');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-|)grammes([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1$2 grams$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-|)gramme([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1$2 gram$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-|)(?:kgs?|\[\[kg\]\])([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1$2 kg$3');
txt.value=txt.value.replace(/({convert\|\d{1,16}\|(?:kg|lb)[^\}]{0,16})\|lk=(?:on|in|out)/g, '$1');
 
//foot
//convert 'foot' to 'ft' when in parentheses
txt.value=txt.value.replace(/(\(\d[\d,\.]{0,16})(?:\s|-|)(?:feet|foot)(\))/g, '$1 ft$2');
txt.value=txt.value.replace(/(\(\d[\d,\.]{0,16}) (?:feet|foot)(\))/g, '$1 ft$2');
 
//remove trailing period when in parentheses
txt.value=txt.value.replace(/(\(\d[\d,\.]{0,16})(?:\s|-|)ft\.(\))/g, '$1 ft$2');
txt.value=txt.value.replace(/(\(\d[\d,\.]{0,16}) ft\.(\))/g, '$1 ft$2');
 
Line 254 ⟶ 231:
txt.value=txt.value.replace(/(\d)(\s|-)square(\s|-)ft/gi, '$1 sq ft');
txt.value=txt.value.replace(/(\d) square ft/gi, '$1 sq ft');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| |)sq(?:\s|-| |)ft([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|sqft|sqm|abbr=on}}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| |)square(?:\s|-| |)feet([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|sqft|sqm}}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| |)square(?:\s|-| |)foot([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|sqft|sqm|sing=on}}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{1,16})(?:\s|-| |)thousand(?:\s|-| |)(?:sq|square)\.?(?:\s|-| |)ft([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2000|sqft|sqm|abbr=on}}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{1,16})(?:\s|-| |)thousand(?:\s|-| |)(?:sq|square)\.?(?:\s|-| |)feet([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2000|sqft|sqm}}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{1,16})(?:\s|-| |)thousand(?:\s|-| |)(?:sq|square)\.?(?:\s|-| |)foot([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2000|sqft|sqm|sing=on}}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{1,16})(?:\s|-| |)million(?:\s|-| |)(?:sq|square)\.?(?:\s|-| |)ft([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2000000|sqft|sqm|abbr=on}}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{1,16})(?:\s|-| |)million(?:\s|-| |)(?:sq|square)\.?(?:\s|-| |)feet([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2000000|sqft|sqm}}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{1,16})(?:\s|-| |)million(?:\s|-| |)(?:sq|square)\.?(?:\s|-| |)foot([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2000000|sqft|sqm|sing=on}}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{1,16})\.(\d)(?:\s|-| |)million(?:\s|-| |)(?:sq|square)\.?(?:\s|-| |)ft([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2$300000|sqft|sqm|abbr=on}}$4');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{1,16})\.(\d)(?:\s|-| |)million(?:\s|-| |)(?:sq|square)\.?(?:\s|-| |)feet([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2$300000|sqft|sqm}}$4');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{1,16})\.(\d)(?:\s|-| |)million(?:\s|-| |)(?:sq|square)\.?(?:\s|-| |)foot([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2$300000|sqft|sqm|sing=on}}$4');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{1,16})\.(\d\d)(?:\s|-| |)million(?:\s|-| |)(?:sq|square)\.?(?:\s|-| |)ft([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2$30000|sqft|sqm|abbr=on}}$4');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{1,16})\.(\d\d)(?:\s|-| |)million(?:\s|-| |)(?:sq|square)\.?(?:\s|-| |)feet([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2$30000|sqft|sqm}}$4');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{1,16})\.(\d\d)(?:\s|-| |)million(?:\s|-| |)(?:sq|square)\.?(?:\s|-| |)foot([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2$30000|sqft|sqm|sing=on}}$4');
 
//feet per second
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-|)(?:ft\/second|ft\/sec)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1$2 ft/s$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16}) (?:ft\/second|ft\/sec)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1$2 ft/s$3');
//feet per second:plural
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| |)feet\sper\ssecond([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|ft/s|m/s}}$3');
//feet per second:singular
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| |)foot\sper\ssecond([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|ft/s|m/s|sing=on}}$3');
//feet per second:abbreviated
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| |)ft\/s([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|ft/s|m/s|abbr=on}}$3');
 
// foot and inch
Line 292 ⟶ 269:
txt.value=txt.value.replace(/yd\.\)/gi, 'yd)');
//yards: plural
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| |)(?:yards|\[\[yard\]\]s|\[\[yards\]\])([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|yd|m}}$3');
//yards: singular
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| |)(?:yard|\[\[yard\]\])([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|yd|m|sing=on}}$3');
//yards: abbreviated
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| |)yd([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|yd|m|abbr=on}}$3');
//yards: in full
txt.value=txt.value.replace(/([^y]\sone(?:\s|-| |)yards?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (1 m)$2');
txt.value=txt.value.replace(/([^y]\stwo(?:\s|-| |)yards?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (2 m)$2');
txt.value=txt.value.replace(/([^y]\sthree(?:\s|-| |)yards?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (3 m)$2');
txt.value=txt.value.replace(/([^y]\sfour(?:\s|-| |)yards?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (4 m)$2');
txt.value=txt.value.replace(/([^y]\sfive(?:\s|-| |)yards?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (5 m)$2');
txt.value=txt.value.replace(/([^y]\ssix(?:\s|-| |)yards?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (5 m)$2');
txt.value=txt.value.replace(/([^y]\sseven(?:\s|-| |)yards?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (6 m)$2');
txt.value=txt.value.replace(/([^y]\seight(?:\s|-| |)yards?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (7 m)$2');
txt.value=txt.value.replace(/([^y]\snine(?:\s|-| |)yards?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (8 m)$2');
txt.value=txt.value.replace(/([^y]\sten(?:\s|-| |)yards?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (9 m)$2');
txt.value=txt.value.replace(/([^y]\seleven(?:\s|-| |)yards?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (10 m)$2');
txt.value=txt.value.replace(/([^y]\stwelve(?:\s|-| |)yards?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (11 m)$2');
txt.value=txt.value.replace(/([^y]\sthirteen(?:\s|-| |)yards?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (12 m)$2');
txt.value=txt.value.replace(/([^y]\sfourteen(?:\s|-| |)yards?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (13 m)$2');
txt.value=txt.value.replace(/([^y]\sfifteen(?:\s|-| |)yards?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (14 m)$2');
txt.value=txt.value.replace(/([^y]\ssixteen(?:\s|-| |)yards?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (15 m)$2');
txt.value=txt.value.replace(/([^y]\sseventeen(?:\s|-| |)yards?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (16 m)$2');
txt.value=txt.value.replace(/([^y]\seighteen(?:\s|-| |)yards?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (16 m)$2');
txt.value=txt.value.replace(/([^y]\snineteen(?:\s|-| |)yards?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (17 m)$2');
txt.value=txt.value.replace(/([^y]\stwenty(?:\s|-| |)yards?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (18 m)$2');
 
// knot
Line 326 ⟶ 303:
 
//nautical mile - rename 'miles' as 'nautical miles' when followed by knots or conversion code
txt.value=txt.value.replace(/(\d)(?:\s|-| |)miles\s(?:at|@)\s([\d\.]{1,9}(?:\s|-| |)knots|{{convert)/gi, '$1 nautical miles at $2');
txt.value=txt.value.replace(/(\d)(\s|-| )(?:mi|nm|nmi)\s(?:at|@)\s([\d\.]{1,9}(?:\s|-| |)knots|{{convert)/gi, '$1$2nmi at $3');
//nautical mile: plural unlinked
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| |)nautical(?:\s|-| |)miles([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|nmi|km}}$3');
//nautical mile: plural linked with 's' inside link
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| |)\[\[nautical(?:\s|-| |)miles\]\]([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|nmi|km}}$3');
//nautical mile: plural linked with 's' outside link
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| |)\[\[nautical(?:\s|-| |)mile\]\]s([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|nmi|km}}$3');
//nautical mile: singular unlinked
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| |)nautical(?:\s|-| |)mile([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|nmi|km|sing=on}}$3');
//nautical mile: singular linked
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| |)\[\[nautical(?:\s|-| |)mile\]\]([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|nmi|km|sing=on}}$3');
//nautical mile: abbreviated
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| |)(?:\[\[nautical\smile\|nmi?\]\]|nmi)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|nmi|km|abbr=on}}$3');
//nautical mile: in full
txt.value=txt.value.replace(/([^y]\sone(?:\s|-| |)nautical(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (1.9 km)$2');
txt.value=txt.value.replace(/([^y]\stwo(?:\s|-| |)nautical(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (4 km)$2');
txt.value=txt.value.replace(/([^y]\sthree(?:\s|-| |)nautical(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (6 km)$2');
txt.value=txt.value.replace(/([^y]\sfour(?:\s|-| |)nautical(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (7 km)$2');
txt.value=txt.value.replace(/([^y]\sfive(?:\s|-| |)nautical(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (9 km)$2');
txt.value=txt.value.replace(/([^y]\ssix(?:\s|-| |)nautical(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (11 km)$2');
txt.value=txt.value.replace(/([^y]\sseven(?:\s|-| |)nautical(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (13 km)$2');
txt.value=txt.value.replace(/([^y]\seight(?:\s|-| |)nautical(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (15 km)$2');
txt.value=txt.value.replace(/([^y]\snine(?:\s|-| |)nautical(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (17 km)$2');
txt.value=txt.value.replace(/([^y]\sten(?:\s|-| |)nautical(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (19 km)$2');
txt.value=txt.value.replace(/([^y]\seleven(?:\s|-| |)nautical(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (20 km)$2');
txt.value=txt.value.replace(/([^y]\stwelve(?:\s|-| |)nautical(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (22 km)$2');
txt.value=txt.value.replace(/([^y]\sthirteen(?:\s|-| |)nautical(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (24 km)$2');
txt.value=txt.value.replace(/([^y]\sfourteen(?:\s|-| |)nautical(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (26 km)$2');
txt.value=txt.value.replace(/([^y]\sfifteen(?:\s|-| |)nautical(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (28 km)$2');
txt.value=txt.value.replace(/([^y]\ssixteen(?:\s|-| |)nautical(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (30 km)$2');
txt.value=txt.value.replace(/([^y]\sseventeen(?:\s|-| |)nautical(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (31 km)$2');
txt.value=txt.value.replace(/([^y]\seighteen(?:\s|-| |)nautical(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (33 km)$2');
txt.value=txt.value.replace(/([^y]\snineteen(?:\s|-| |)nautical(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (35 km)$2');
txt.value=txt.value.replace(/([^y]\stwenty(?:\s|-| |)nautical(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (37 km)$2');
 
//knot - plural
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| |)(?:knots|\[\[knot\s\(speed\)\|(?:knots\]\]|knot\]\]s))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|knot|km/h}}$3');
//knot - singular
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| |)(?:knot|\[\[knot\s\(speed\)\|knot\]\])([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|knot|km/h|sing=on}}$3');
//knot - abbreviation
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| |)(?:kts?|\[\[knot\s\(speed\)\|kts?\]\])([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|knot|km/h|abbr=on}}$3');
 
//mile - lower case to avoid proper names like 'Five Mile Road'
Line 373 ⟶ 350:
txt.value=txt.value.replace(/(miles?)\s(per)/gi, '$1xx$2');
//miles: plural
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| |)(?:miles|\[\[miles\]\]|\[\[mile\]\]s)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1{{convert|$2|mi|km}}$3');
//miles: singular
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| |)(?:mile|\[\[mile\]\])([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1{{convert|$2|mi|km|sing=on}}$3');
//miles: abbreviated
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| |)mi([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1{{convert|$2|mi|km|abbr=on}}$3');
//miles: in full
txt.value=txt.value.replace(/([^y]\sone(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1 (1.6 km)$2');
txt.value=txt.value.replace(/([^y]\stwo(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1 (3 km)$2');
txt.value=txt.value.replace(/([^y]\sthree(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1 (5 km)$2');
txt.value=txt.value.replace(/([^y]\sfour(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1 (6 km)$2');
txt.value=txt.value.replace(/([^y]\sfive(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1 (8 km)$2');
txt.value=txt.value.replace(/([^y]\ssix(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1 (10 km)$2');
txt.value=txt.value.replace(/([^y]\sseven(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1 (11 km)$2');
txt.value=txt.value.replace(/([^y]\seight(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1 (13 km)$2');
txt.value=txt.value.replace(/([^y]\snine(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1 (14 km)$2');
txt.value=txt.value.replace(/([^y]\sten(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1 (16 km)$2');
txt.value=txt.value.replace(/([^y]\seleven(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1 (18 km)$2');
txt.value=txt.value.replace(/([^y]\stwelve(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1 (19 km)$2');
txt.value=txt.value.replace(/([^y]\sthirteen(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1 (19 km)$2');
txt.value=txt.value.replace(/([^y]\sfourteen(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1 (21 km)$2');
txt.value=txt.value.replace(/([^y]\sfifteen(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1 (24 km)$2');
txt.value=txt.value.replace(/([^y]\sixteen(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1 (26 km)$2');
txt.value=txt.value.replace(/([^y]\sseventeen(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1 (27 km)$2');
txt.value=txt.value.replace(/([^y]\seighteen(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1 (29 km)$2');
txt.value=txt.value.replace(/([^y]\snineteen(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1 (30 km)$2');
txt.value=txt.value.replace(/([^y]\stwenty(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1 (32 km)$2');
 
//mile - unprotect 'miles per hour'
Line 404 ⟶ 381:
 
//mile per hour
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| |)m\.?p\.?h([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1{{convert|$2|mi/h|km/h|abbr=on}}$3');
 
// square mile
Line 410 ⟶ 387:
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|-| |)(mile)/gi, '$1uare $2');
// square mile:plural
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| |)square(?:\s|-| |)miles([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|sqmi|sqkm}}$3');
// square mile:singular
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| |)square(?:\s|-| |)mile([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|sqmi|sqkm|sing=on}}$3');
// square mile:abbreviated
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| |)sq(?:\s|-| |)mi([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|sqmi|sqkm|abbr=on}}$3');
 
//acre foot:plural
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{3,16}[\d,\.]{0,16})(?:\s|-| |)acre(?:\s|-| |)feet([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1{{convert|$2|acre feet}}$3');
//acre foot:singular
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{3,16}[\d,\.]{0,16})(?:\s|-| |)acre(?:\s|-| |)foot([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1{{convert|$2|acre feet|sing=on}}$3');
//acre foot:abbreviation
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{3,16}[\d,\.]{0,16})(?:\s|-| |)(?:acre|ac\.?)(?:\s|-| |)(?:foot|feet|ft)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1{{convert|$2|acre ft|abbr=on}}$3');
 
 
Line 430 ⟶ 407:
txt.value=txt.value.replace(/(acre.feet)/gi, 'xtempx$1ytempy');
txt.value=txt.value.replace(/(\d)-(acre)/gi, '$1 $2');
txt.value=txt.value.replace(/(\d)(?:\s|-| |)surface(?:\s|-| |)acre/gi, '$1 acre');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{1,16})(?:\s|-| |)thousand(?:\s|-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2000|acre|sqkm}}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{1,16})(?:\s|-| |)thousand(?:\s|-| |)(?:acre|\[\[acre\]\])([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2000|acre|sqkm|sing=on}}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{1,16})(?:\s|-| |)million(?:\s|-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2000000|acre|sqkm}}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{1,16})(?:\s|-| |)million(?:\s|-| |)(?:acre|\[\[acre\]\])([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2000000|acre|sqkm|sing=on}}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{1,16})\.(\d)(?:\s|-| |)million(?:\s|-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2$300000|acre|sqkm}}$4');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{1,16})\.(\d)(?:\s|-| |)million(?:\s|-| |)(?:acre|\[\[acre\]\])([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2$300000|acre|sqkm|sing=on}}$4');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{1,16})\.(\d\d)(?:\s|-| |)million(?:\s|-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2$30000|acre|sqkm}}$4');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{1,16})\.(\d\d)(?:\s|-| |)million(?:\s|-| |)(?:acre|\[\[acre\]\])([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2$30000|acre|sqkm|sing=on}}$4');
txt.value=txt.value.replace(/([^y]\sone(?:\s|-| |)million(?:\s|-| |)acres?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (4,000 km²)$2');
txt.value=txt.value.replace(/(\sa(?:\s|-| |)million(?:\s|-| |)acres?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (4,000 km²)$2');
txt.value=txt.value.replace(/([^y]\stwo(?:\s|-| |)million(?:\s|-| |)acres?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (8,000 km²)$2');
txt.value=txt.value.replace(/([^y]\sthree(?:\s|-| |)million(?:\s|-| |)acres?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (12,000 km²)$2');
txt.value=txt.value.replace(/([^y]\sfour(?:\s|-| |)million(?:\s|-| |)acres?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (16,000 km²)$2');
txt.value=txt.value.replace(/([^y]\sfive(?:\s|-| |)million(?:\s|-| |)acres?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (20,000 km²)$2');
txt.value=txt.value.replace(/([^y]\ssix(?:\s|-| |)million(?:\s|-| |)acres?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (24,000 km²)$2');
txt.value=txt.value.replace(/([^y]\sseven(?:\s|-| |)million(?:\s|-| |)acres?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (28,000 km²)$2');
txt.value=txt.value.replace(/([^y]\seight(?:\s|-| |)million(?:\s|-| |)acres?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (32,000 km²)$2');
txt.value=txt.value.replace(/([^y]\snine(?:\s|-| |)million(?:\s|-| |)acres?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (36,000 km²)$2');
txt.value=txt.value.replace(/([^y]\sten(?:\s|-| |)million(?:\s|-| |)acres?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (40,000 km²)$2');
 
//acre:plural
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{3,16}[\d,\.]{0,16})(?:\s|-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1{{convert|$2|acre|sqkm}}$3');
//acre:singular
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)([\d,]{3,16}[\d,\.]{0,16})(?:\s|-| |)(?:acre|\[\[acre\]\])([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1{{convert|$2|acre|sqkm|sing=on}}$3');
 
//undo protection for acre feet
Line 467 ⟶ 444:
txt.value=txt.value.replace(/ft[\s-.·•\/]{1,2}lbf([^\|])/gi, 'ft·lbf$1');
txt.value=txt.value.replace(/ft[\s-.·•\/]{1,2}lbff/gi, 'ft·lbf');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| |)ft.lbf([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1{{convert|$2|ft.lbf|N.m|abbr=on}}$3');
 
// pound force
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(\s|-| |)lbs?.?\s(thrust|of\sthrust|force|of\sforce)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1$2$3lbf $4$5');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16}000)(?:\s|-| |)lbfpounds\sforce([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|lbf|kN|abbr=on}}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| |)lbfpounds\sforce([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|lbf|abbr=onN}}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16}000)(?:\s|-| |)pound\sforce([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|lbf|kN|sing=on}}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)pound\sforce([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|lbf|N|sing=on}}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16}000)(?:\s|-| |)lbf([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|lbf|kN|abbr=on}}$3');
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)lbf([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|lbf|abbr=on}}$3');
 
// pound weight. Parsed after foot pound and pound force
Line 480 ⟶ 461:
txt.value=txt.value.replace(/(\d\+?)\s?lbs?([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 lb$2');
txt.value=txt.value.replace(/(\d) lbs?([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 lb$2');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| |)lb([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|lb|abbr=on}}$3');
//pounds and ounces - plural
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)pounds(?:\s|-| |)(\d[\d,\.]{0,16})(?:\s|-| |)ounces?([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|lb|$3|oz|kg}}$4');
//pounds and ounces - singular
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)pound(?:\s|-| |)(\d[\d,\.]{0,16})(?:\s|-| |)ounces?([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|lb|$3|oz|kg|sing=on}}$4');
//pounds and ounces - abbreviated
txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)lbs?\.?,?(?:\s|-| |)(\d[\d,\.]{0,16})(?:\s|-| |)oz\.?([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|lb|$3|oz|kg|abbr=on}}$4');
 
//foot and inch: plural
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| |)feet\.?(?:\s|-| |)(\d[\d,\.]{0,16})(?:\s|-| |)(?:in|ins|inch|inches)\.?([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|ft|$3|in|m}}$4');
//foot and inch: singular
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| |)foot\.?(?:\s|-| |)(\d[\d,\.]{0,16})(?:\s|-| |)(?:in|ins|inch|inches)\.?([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|ft|$3|in|m|sing=on}}$4');
//foot and inch: abbreviated
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| |)ft\.?(?:\s|-| |)(\d[\d,\.]{0,16})(?:\s|-| |)(?:in|ins|inch|inches)\.?([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|ft|$3|in|m|abbr=on}}$4');
 
//foot (again). Parsed after 'foot per second' and 'foot pound'
//foot: plural
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| |)feet([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|ft|m}}$3');
//foot: singular
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| |)foot([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|ft|m|sing=on}}$3');
//foot: abbreviated
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| |)ft\.?([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|ft|m|abbr=on}}$3');
 
//inch: plural
txt.value=txt.value.replace(/([^\Wt'’]\s)(\d[\d,\.]{0,16})(?:\s|-| |)inches([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|in|mm}}$3');
// inch: plural with number in words
txt.value=txt.value.replace(/([^ty]\sthree(?:\s|-| |)(?:inches|\[\[inches\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (76 mm) $2');
txt.value=txt.value.replace(/([^ty]\sfour(?:\s|-| |)(?:inches|\[\[inches\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (102 mm) $2');
txt.value=txt.value.replace(/([^ty]\sfive(?:\s|-| |)(?:inches|\[\[inches\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (127 mm) $2');
txt.value=txt.value.replace(/([^ty]\ssix(?:\s|-| |)(?:inches|\[\[inches\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (152 mm) $2');
txt.value=txt.value.replace(/([^ty]\sseven(?:\s|-| |)(?:inches|\[\[inches\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (178 mm) $2');
txt.value=txt.value.replace(/([^ty]\seight(?:\s|-| |)(?:inches|\[\[inches\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (203 mm) $2');
txt.value=txt.value.replace(/([^ty]\snine(?:\s|-| |)(?:inches|\[\[inches\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (229 mm) $2');
txt.value=txt.value.replace(/([^ty]\sten(?:\s|-| |)(?:inches|\[\[inches\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (254 mm) $2');
txt.value=txt.value.replace(/([^ty]\seleven(?:\s|-| |)(?:inches|\[\[inches\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (279 mm) $2');
txt.value=txt.value.replace(/([^ty]\stwelve(?:\s|-| |)(?:inches|\[\[inches\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (305 mm) $2');
txt.value=txt.value.replace(/([^ty]\sthirteen(?:\s|-| |)(?:inches|\[\[inches\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (330 mm) $2');
txt.value=txt.value.replace(/([^ty]\sfourteen(?:\s|-| |)(?:inches|\[\[inches\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (356 mm) $2');
txt.value=txt.value.replace(/([^ty]\sfifteen(?:\s|-| |)(?:inches|\[\[inches\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (381 mm) $2');
txt.value=txt.value.replace(/([^ty]\ssixteen(?:\s|-| |)(?:inches|\[\[inches\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (406 mm) $2');
 
//inch: singular
txt.value=txt.value.replace(/([^\Wt'’]\s)(\d[\d,\.]{0,16})(?:\s|-| |)(?:inch|\[\[inch\]\])([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|in|mm|sing=on}}$3');
txt.value=txt.value.replace(/({convert\|\d{1,16}\|(?:in|mm|cm)[^\}]{0,16})\|lk=(?:on|in|out)/g, '$1');
 
txt.value=txt.value.replace(/([^\d]\s)(\d{1,3})?,?(\d{1,3}00)(?:\s|-| )in([^²³ches\(\)]{3})/gi, '$1{{Auto in|$2$3|1}}$4');
txt.value=txt.value.replace(/([^\d]\s)(\d{1,3})?,?(\d{1,3}0)(?:\s|-| )in([^²³ches\(\)]{3})/gi, '$1{{Auto in|$2$3|1}}$4');
txt.value=txt.value.replace(/([^\d]\s)(\d{1,3})?,?(\d{1,3})(?:\s|-| )in([^²³ches\(\)]{3})/gi, '$1{{Auto in|$2$3|1}}$4');
txt.value=txt.value.replace(/([^\d]\s)(\d{1,3}\.\d)(?:\s|-| )in([^²³ches\(\)]{3})/gi, '$1{{Auto in|$2|0}}$3');
txt.value=txt.value.replace(/([^\d]\s)(\d{1,3}\.\d\d)(?:\s|-| )in([^²³ches\(\)]{3})/gi, '$1{{Auto in|$2|0}}$3');
txt.value=txt.value.replace(/([^\d]\s)(\d{1,3}\.\d\d\d)(?:\s|-| )in([^²³ches\(\)]{3})/gi, '$1{{Auto in|$2|0}}$3');
 
 
 
// inch: singular with number in words
txt.value=txt.value.replace(/([^ty]\sthree(?:\s|-| |)(?:inch|\[\[inch\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (76 mm) $2');
txt.value=txt.value.replace(/([^ty]\sfour(?:\s|-| |)(?:inch|\[\[inch\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (102 mm) $2');
txt.value=txt.value.replace(/([^ty]\sfive(?:\s|-| |)(?:inch|\[\[inch\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (127 mm) $2');
txt.value=txt.value.replace(/([^ty]\ssix(?:\s|-| |)(?:inch|\[\[inch\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (152 mm) $2');
txt.value=txt.value.replace(/([^ty]\sseven(?:\s|-| |)(?:inch|\[\[inch\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (178 mm) $2');
txt.value=txt.value.replace(/([^ty]\seight(?:\s|-| |)(?:inch|\[\[inch\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (203 mm) $2');
txt.value=txt.value.replace(/([^ty]\snine(?:\s|-| |)(?:inch|\[\[inch\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (229 mm) $2');
txt.value=txt.value.replace(/([^ty]\sten(?:\s|-| |)(?:inch|\[\[inch\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (254 mm) $2');
txt.value=txt.value.replace(/([^ty]\seleven(?:\s|-| |)(?:inch|\[\[inch\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (279 mm) $2');
txt.value=txt.value.replace(/([^ty]\stwelve(?:\s|-| |)(?:inch|\[\[inch\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (305 mm) $2');
txt.value=txt.value.replace(/([^ty]\sthirteen(?:\s|-| |)(?:inch|\[\[inch\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (330 mm) $2');
txt.value=txt.value.replace(/([^ty]\sfourteen(?:\s|-| |)(?:inch|\[\[inch\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (356 mm) $2');
txt.value=txt.value.replace(/([^ty]\sfifteen(?:\s|-| |)(?:inch|\[\[inch\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (381 mm) $2');
txt.value=txt.value.replace(/([^ty]\ssixteen(?:\s|-| |)(?:inch|\[\[inch\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (406 mm) $2');
 
// horsepower
Line 549 ⟶ 525:
txt.value=txt.value.replace(/(\d) (horsepower|hp|bhp|ihp|shp)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 $2$3');
txt.value=txt.value.replace(/(\d)(?:\s|-|)horse(?:\s|-|)power([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 horsepower$2');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| |)(?:horsepower|\[\[horsepower\]\])([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|hp}}$43');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| |)(indicated(?:\s|-| |)horsepower)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|ihp}}$4');
txt.value=txt.value.replace(/([^\d\(\)\/\\=]\s)(\d[\d,\.]{0,16})(?:\s|-| |)(hp|bhp|ihp|shp)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|$3|abbr=on}}$4');
 
 
// Newton metre
txt.value=txt.value.replace(/(\d)\s?Nm/gi, '$1 Nm');
txt.value=txt.value.replace(/(\d) Nm/gi, '$1 Nm');
 
txt.value=txt.value.replace(/([^\d]\s)(\d{1,3})?,?(\d{1,3}00)(?:\s|-| )Nm([^\(\)]{3})/gi, '$1{{Auto Nm|$2$3|0}}$4');
txt.value=txt.value.replace(/([^\d]\s)(\d{1,3})?,?(\d{1,3}0)(?:\s|-| )Nm([^\(\)]{3})/gi, '$1{{Auto Nm|$2$3|0}}$4');
txt.value=txt.value.replace(/([^\d]\s)(\d{1,3})?,?(\d{1,3})(?:\s|-| )Nm([^\(\)]{3})/gi, '$1{{Auto Nm|$2$3|0}}$4');
txt.value=txt.value.replace(/([^\d]\s)(\d{1,3}\.\d\d)(?:\s|-| )Nm([^\(\)]{3})/gi, '$1{{Auto Nm|$2|0}}$3');
txt.value=txt.value.replace(/([^\d]\s)(\d{1,3}\.\d\d\d)(?:\s|-| )Nm([^\(\)]{3})/gi, '$1{{Auto Nm|$2|0}}$3');
 
 
txt.value=txt.value.replace(/([^\d]\s)(\d{1,3})?,?(\d{1,3}00)(?:\s|-| )N·m([^\(\)]{3})/gi, '$1{{Auto Nm|$2$3|0}}$4');
txt.value=txt.value.replace(/([^\d]\s)(\d{1,3})?,?(\d{1,3}0)(?:\s|-| )N·m([^\(\)]{3})/gi, '$1{{Auto Nm|$2$3|0}}$4');
txt.value=txt.value.replace(/([^\d]\s)(\d{1,3})?,?(\d{1,3})(?:\s|-| )N·m([^\(\)]{3})/gi, '$1{{Auto Nm|$2$3|0}}$4');
txt.value=txt.value.replace(/([^\d]\s)(\d{1,3}\.\d\d)(?:\s|-| )N·m([^\(\)]{3})/gi, '$1{{Auto Nm|$2|0}}$3');
txt.value=txt.value.replace(/([^\d]\s)(\d{1,3}\.\d\d\d)(?:\s|-| )N·m([^\(\)]{3})/gi, '$1{{Auto Nm|$2|0}}$3');
txt.value=txt.value.replace(/([^\d]\s)(\d{1,3})?,?(\d{1,3})(?:\s|-| )N·m([^\(\)]{3})/gi, '$1{{Auto Nm|$2$3|0}}$4');
 
// kilometre per hour
txt.value=txt.value.replace(/km\/hr(\W)/gi, 'km/h$1');
txt.value=txt.value.replace(/km\/ph(\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) kmh/gi, '$1 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) km\/h/gi, '$1 km/h');
 
//Test
txt.value=txt.value.replace(/([^\d]\s)(\d{1,3}00),?(000)(?:\s|-| )km\/h([^\(\)]{3})/gi, '$1{{Auto km/h|$2$3|0}}$4');
txt.value=txt.value.replace(/([^\d]\s)(\d{1,3}0),?(000)(?:\s|-| )km\/h([^\(\)]{3})/gi, '$1{{Auto km/h|$2$3|0}}$4');
txt.value=txt.value.replace(/([^\d]\s)(\d{1,3}),?(000)(?:\s|-| )km\/h([^\(\)]{3})/gi, '$1{{Auto km/h|$2$3|0}}$4');
txt.value=txt.value.replace(/([^\d]\s)(\d{1,3})?,?(\d{1,3}00)(?:\s|-| )km\/h([^\(\)]{3})/gi, '$1{{Auto km/h|$2$3|0}}$4');
txt.value=txt.value.replace(/([^\d]\s)(\d{1,3})?,?(\d{1,3}0)(?:\s|-| )km\/h([^\(\)]{3})/gi, '$1{{Auto km/h|$2$3|0}}$4');
txt.value=txt.value.replace(/([^\d]\s)(\d{1,3})?,?(\d{1,3})(?:\s|-| )km\/h([^\(\)]{3})/gi, '$1{{Auto km/h|$2$3|0}}$4');
txt.value=txt.value.replace(/([^\d]\s)(\d{1,3}\.\d\d)(?:\s|-| )km\/h([^\(\)]{3})/gi, '$1{{Auto km/h|$2|0}}$3');
txt.value=txt.value.replace(/([^\d]\s)(\d{1,3}\.\d\d\d)(?:\s|-| )km\/h([^\(\)]{3})/gi, '$1{{Auto km/h|$2|0}}$3');
 
 
 
 
 
 
 
// rpm
Line 628 ⟶ 556:
// space with bits and bytes
txt.value=txt.value.replace(/([^\w]\d)\s?(k|M|G|T)(bit|B)/g, '$1 $2$3');
 
//aviation specifications: unprotect 'main=' and 'alt='
txt.value=txt.value.replace(/((?:main|alt)\s?=\s?)xx(\d)/gi, '$1$2');
 
//change format of convert template variables
Line 752 ⟶ 683:
// Add a tag to the summary box
var txt = document.editform.wpSummary;
var summary = "[[User:Lightmouse/monobook.js|Script]] assisted. Units/dates/other/[[WP:CARS]] Conventions";
if (txt.value.indexOf(summary) == -1) {
if (txt.value.match(/[^\*\/\s][^\/\s]?\s*$/)) {
Line 775 ⟶ 706:
// Add a tag to the summary box
var txt = document.editform.wpSummary;
var summary = "[[User:Lightmouse/monobook.js|Script]] assisted. Units/dates/other/[[WP:CARS]] Conventions";
if (txt.value.indexOf(summary) == -1) {
if (txt.value.match(/[^\*\/\s][^\/\s]?\s*$/)) {
Line 799 ⟶ 730:
// Add a tag to the summary box
var txt = document.editform.wpSummary;
var summary = "[[User:Lightmouse/monobook.js|Script]] assisted. Units/dates/other/[[WP:CARS]] Conventions";
if (txt.value.indexOf(summary) == -1) {
if (txt.value.match(/[^\*\/\s][^\/\s]?\s*$/)) {