User:Bobblewik/monobook.js/general.js
From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Firefox/Mozilla/Safari: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Internet Explorer: press Ctrl-F5, Opera/Konqueror: press F5.
//'winc' function allows buttons to be added toolbar winc('User:Omegatron/monobook.js/addlink.js'); function formatgeneral() { var txt = document.editform.wpTextbox1; //Attempt to deal with naval infobox //real symbol for 'times' txt.value = txt.value.replace(/×/gi, '×'); txt.value = txt.value.replace(/General\sCharacteristics/g, 'General characteristics'); //expand torpedo tube abbreviation txt.value = txt.value.replace(/inch\st\.?t\.?/g, 'inch torpedo tubes'); //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(/one\s5\-inch\/([\d]{1,2})\sdeck\sgun/g, '1 x 5 in (127 mm)\$1 cal deck gun'); //Attempt to deal with naval infobox //3 inch txt.value = txt.value.replace(/one\s3[\-\s]inch\s([^\(])/gi, '1 × 3 in (76 mm) $1'); txt.value = txt.value.replace(/two\s3[\-\s]inch\s([^\(])/gi, '2 × 3 in (76 mm) $1'); txt.value = txt.value.replace(/three\s3[\-\s]inch\s([^\(])/gi, '3 × 3 in (76 mm) $1'); txt.value = txt.value.replace(/four\s3[\-\s]inch\s([^\(])/gi, '4 × 3 in (76 mm) $1'); txt.value = txt.value.replace(/five\s3[\-\s]inch\s([^\(])/gi, '5 × 3 in (76 mm) $1'); txt.value = txt.value.replace(/six\s3[\-\s]inch\s([^\(])/gi, '6 × 3 in (76 mm) $1'); txt.value = txt.value.replace(/seven\s3[\-\s]inch\s([^\(])/gi, '7 × 3 in (76 mm) $1'); txt.value = txt.value.replace(/eight\s3[\-\s]inch\s([^\(])/gi, '8 × 3 in (76 mm) $1'); txt.value = txt.value.replace(/(\d)\s[x×]\sthree[\-\s]inch/gi, '$1 × 3 in (76 mm)'); txt.value = txt.value.replace(/(\d)\s[x×]\s3[\-\s]inch/gi, '$1 × 3 in (76 mm)'); txt.value = txt.value.replace(/\(76\s?mm\)\s?\(76\s?mm\)/gi, '(76 mm)'); //4 inch txt.value = txt.value.replace(/one\s4[\-\s]inch\s([^\(])/gi, '1 × 4 in (102 mm) $1'); txt.value = txt.value.replace(/two\s4[\-\s]inch\s([^\(])/gi, '2 × 4 in (102 mm) $1'); txt.value = txt.value.replace(/three\s4[\-\s]inch\s([^\(])/gi, '3 × 4 in (102 mm) $1'); txt.value = txt.value.replace(/four\s4[\-\s]inch\s([^\(])/gi, '4 × 4 in (102 mm) $1'); txt.value = txt.value.replace(/five\s4[\-\s]inch\s([^\(])/gi, '5 × 4 in (102 mm) $1'); txt.value = txt.value.replace(/six\s4[\-\s]inch\s([^\(])/gi, '6 × 4 in (102 mm) $1'); txt.value = txt.value.replace(/seven\s4[\-\s]inch\s([^\(])/gi, '7 × 4 in (102 mm) $1'); txt.value = txt.value.replace(/eight\s4[\-\s]inch\s([^\(])/gi, '8 × 4 in (102 mm) $1'); txt.value = txt.value.replace(/(\d)\s[x×]\sfour[\-\s]inch/gi, '$1 × 4 in (102 mm)'); txt.value = txt.value.replace(/(\d)\s[x×]\s4[\-\s]inch/gi, '$1 × 4 in (102 mm)'); txt.value = txt.value.replace(/\(102\s?mm\)\s?\(102\s?mm\)/gi, '(102 mm)'); //5 inch txt.value = txt.value.replace(/one\s5[\-\s]inch\s([^\(])/gi, '1 × 5 in (127 mm) $1'); txt.value = txt.value.replace(/two\s5[\-\s]inch\s([^\(])/gi, '2 × 5 in (127 mm) $1'); txt.value = txt.value.replace(/three\s5[\-\s]inch\s([^\(])/gi, '3 × 5 in (127 mm) $1'); txt.value = txt.value.replace(/four\s5[\-\s]inch\s([^\(])/gi, '4 × 5 in (127 mm) $1'); txt.value = txt.value.replace(/five\s5[\-\s]inch\s([^\(])/gi, '5 × 5 in (127 mm) $1'); txt.value = txt.value.replace(/six\s5[\-\s]inch\s([^\(])/gi, '6 × 5 in (127 mm) $1'); txt.value = txt.value.replace(/seven\s5[\-\s]inch\s([^\(])/gi, '7 × 5 in (127 mm) $1'); txt.value = txt.value.replace(/eight\s5[\-\s]inch\s([^\(])/gi, '8 × 5 in (127 mm) $1'); txt.value = txt.value.replace(/(\d)\s[x×]\s5[\-\s]inch/gi, '$1 × 5 in (127 mm)'); txt.value = txt.value.replace(/(\d)\s[x×]\sfive[\-\s]inch/gi, '$1 × 5 in (127 mm)'); txt.value = txt.value.replace(/\(127\s?mm\)\s?\(127\s?mm\)/gi, '(127 mm)'); //6 inch txt.value = txt.value.replace(/one\s6[\-\s]inch\s([^\(])/gi, '1 × 6 in (152 mm) $1'); txt.value = txt.value.replace(/two\s6[\-\s]inch\s([^\(])/gi, '2 × 6 in (152 mm) $1'); txt.value = txt.value.replace(/three\s6[\-\s]inch\s([^\(])/gi, '3 × 6 in (152 mm) $1'); txt.value = txt.value.replace(/four\s6[\-\s]inch\s([^\(])/gi, '4 × 6 in (152 mm) $1'); txt.value = txt.value.replace(/five\s6[\-\s]inch\s([^\(])/gi, '5 × 6 in (152 mm) $1'); txt.value = txt.value.replace(/six\s6[\-\s]inch\s([^\(])/gi, '6 × 6 in (152 mm) $1'); txt.value = txt.value.replace(/seven\s6[\-\s]inch\s([^\(])/gi, '7 × 6 in (152 mm) $1'); txt.value = txt.value.replace(/eight\s6[\-\s]inch\s([^\(])/gi, '8 × 6 in (152 mm) $1'); txt.value = txt.value.replace(/(\d)\s[x×]\s6[\-\s]inch/gi, '$1 × 6 in (152 mm)'); txt.value = txt.value.replace(/(\d)\s[x×]\ssix[\-\s]inch/gi, '$1 × 6 in (152 mm)'); txt.value = txt.value.replace(/\(152\s?mm\)\s?\(152\s?mm\)/gi, '(152 mm)'); //7 inch txt.value = txt.value.replace(/one\s7[\-\s]inch\s([^\(])/gi, '1 × 7 in (178 mm) $1'); txt.value = txt.value.replace(/two\s7[\-\s]inch\s([^\(])/gi, '2 × 7 in (178 mm) $1'); txt.value = txt.value.replace(/three\s7[\-\s]inch\s([^\(])/gi, '3 × 7 in (178 mm) $1'); txt.value = txt.value.replace(/four\s7[\-\s]inch\s([^\(])/gi, '4 × 7 in (178 mm) $1'); txt.value = txt.value.replace(/five\s7[\-\s]inch\s([^\(])/gi, '5 × 7 in (178 mm) $1'); txt.value = txt.value.replace(/six\s7[\-\s]inch\s([^\(])/gi, '6 × 7 in (178 mm) $1'); txt.value = txt.value.replace(/seven\s7[\-\s]inch\s([^\(])/gi, '7 × 7 in (178 mm) $1'); txt.value = txt.value.replace(/eight\s7[\-\s]inch\s([^\(])/gi, '8 × 7 in (178 mm) $1'); txt.value = txt.value.replace(/(\d)\s[x×]\sseven[\-\s]inch/gi, '$1 × 7 in (178 mm)'); txt.value = txt.value.replace(/(\d)\s[x×]\s7[\-\s]inch/gi, '$1 × 7 in (178 mm)'); txt.value = txt.value.replace(/\(178\s?mm\)\s?\(178\s?mm\)/gi, '(178 mm)'); //8 inch txt.value = txt.value.replace(/one\s8[\-\s]inch\s([^\(])/gi, '1 × 8 in (203 mm) $1'); txt.value = txt.value.replace(/two\s8[\-\s]inch\s([^\(])/gi, '2 × 8 in (203 mm) $1'); txt.value = txt.value.replace(/three\s8[\-\s]inch\s([^\(])/gi, '3 × 8 in (203 mm) $1'); txt.value = txt.value.replace(/four\s8[\-\s]inch\s([^\(])/gi, '4 × 8 in (203 mm) $1'); txt.value = txt.value.replace(/five\s8[\-\s]inch\s([^\(])/gi, '5 × 8 in (203 mm) $1'); txt.value = txt.value.replace(/six\s8[\-\s]inch\s([^\(])/gi, '6 × 8 in (203 mm) $1'); txt.value = txt.value.replace(/seven\s8[\-\s]inch\s([^\(])/gi, '7 × 8 in (203 mm) $1'); txt.value = txt.value.replace(/eight\s8[\-\s]inch\s([^\(])/gi, '8 × 8 in (203 mm) $1'); txt.value = txt.value.replace(/(\d)\s[x×]\s8[\-\s]inch/gi, '$1 × 8 in (203 mm)'); txt.value = txt.value.replace(/(\d)\s[x×]\seight[\-\s]inch/gi, '$1 × 8 in (203 mm)'); txt.value = txt.value.replace(/\(203\s?mm\)\s?\(203\s?mm\)/gi, '(203 mm)'); //9 inch txt.value = txt.value.replace(/one\s9[\-\s]inch\s([^\(])/gi, '1 × 9 in (229 mm) $1'); txt.value = txt.value.replace(/two\s9[\-\s]inch\s([^\(])/gi, '2 × 9 in (229 mm) $1'); txt.value = txt.value.replace(/three\s9[\-\s]inch\s([^\(])/gi, '3 × 9 in (229 mm) $1'); txt.value = txt.value.replace(/four\s9[\-\s]inch\s([^\(])/gi, '4 × 9 in (229 mm) $1'); txt.value = txt.value.replace(/five\s9[\-\s]inch\s([^\(])/gi, '5 × 9 in (229 mm) $1'); txt.value = txt.value.replace(/six\s9[\-\s]inch\s([^\(])/gi, '6 × 9 in (229 mm) $1'); txt.value = txt.value.replace(/seven\s9[\-\s]inch\s([^\(])/gi, '7 × 9 in (229 mm) $1'); txt.value = txt.value.replace(/eight\s9[\-\s]inch\s([^\(])/gi, '9 × 9 in (229 mm) $1'); txt.value = txt.value.replace(/(\d)\s[x×]\s9[\-\s]inch/gi, '$1 × 9 in (229 mm)'); txt.value = txt.value.replace(/(\d)\s[x×]\snine[\-\s]inch/gi, '$1 × 9 in (229 mm)'); txt.value = txt.value.replace(/\(229\s?mm\)\s?\(229\s?mm\)/gi, '(229 mm)'); //10 inch txt.value = txt.value.replace(/one\s10[\-\s]inch\s([^\(])/gi, '1 × 10 in (254 mm) $1'); txt.value = txt.value.replace(/two\s10[\-\s]inch\s([^\(])/gi, '2 × 10 in (254 mm) $1'); txt.value = txt.value.replace(/three\s10[\-\s]inch\s([^\(])/gi, '3 × 10 in (254 mm) $1'); txt.value = txt.value.replace(/four\s10[\-\s]inch\s([^\(])/gi, '4 × 10 in (254 mm) $1'); txt.value = txt.value.replace(/five\s10[\-\s]inch\s([^\(])/gi, '5 × 10 in (254 mm) $1'); txt.value = txt.value.replace(/six\s10[\-\s]inch\s([^\(])/gi, '6 × 10 in (254 mm) $1'); txt.value = txt.value.replace(/seven\s10[\-\s]inch\s([^\(])/gi, '7 × 10 in (254 mm) $1'); txt.value = txt.value.replace(/eight\s10[\-\s]inch\s([^\(])/gi, '10 × 10 in (254 mm) $1'); txt.value = txt.value.replace(/(\d)\s[x×]\s10[\-\s]inch/gi, '$1 × 10 in (254 mm)'); txt.value = txt.value.replace(/(\d)\s[x×]\sten[\-\s]inch/gi, '$1 × 10 in (254 mm)'); txt.value = txt.value.replace(/\(254\s?mm\)\s?\(254\s?mm\)/gi, '(254 mm)'); //11 inch txt.value = txt.value.replace(/one\s11[\-\s]inch\s([^\(])/gi, '1 × 11 in (279 mm) $1'); txt.value = txt.value.replace(/two\s11[\-\s]inch\s([^\(])/gi, '2 × 11 in (279 mm) $1'); txt.value = txt.value.replace(/three\s11[\-\s]inch\s([^\(])/gi, '3 × 11 in (279 mm) $1'); txt.value = txt.value.replace(/four\s11[\-\s]inch\s([^\(])/gi, '4 × 11 in (279 mm) $1'); txt.value = txt.value.replace(/five\s11[\-\s]inch\s([^\(])/gi, '5 × 11 in (279 mm) $1'); txt.value = txt.value.replace(/six\s11[\-\s]inch\s([^\(])/gi, '6 × 11 in (279 mm) $1'); txt.value = txt.value.replace(/seven\s11[\-\s]inch\s([^\(])/gi, '7 × 11 in (279 mm) $1'); txt.value = txt.value.replace(/eight\s11[\-\s]inch\s([^\(])/gi, '11 × 11 in (279 mm) $1'); txt.value = txt.value.replace(/(\d)\s[x×]\s11[\-\s]inch/gi, '$1 × 11 in (279 mm)'); txt.value = txt.value.replace(/(\d)\s[x×]\seleven[\-\s]inch/gi, '$1 × 11 in (279 mm)'); txt.value = txt.value.replace(/\(279\s?mm\)\s?\(279\s?mm\)/gi, '(279 mm)'); //12 inch txt.value = txt.value.replace(/one\s12[\-\s]inch\s([^\(])/gi, '1 × 12 in (305 mm) $1'); txt.value = txt.value.replace(/two\s12[\-\s]inch\s([^\(])/gi, '2 × 12 in (305 mm) $1'); txt.value = txt.value.replace(/three\s12[\-\s]inch\s([^\(])/gi, '3 × 12 in (305 mm) $1'); txt.value = txt.value.replace(/four\s12[\-\s]inch\s([^\(])/gi, '4 × 12 in (305 mm) $1'); txt.value = txt.value.replace(/five\s12[\-\s]inch\s([^\(])/gi, '5 × 12 in (305 mm) $1'); txt.value = txt.value.replace(/six\s12[\-\s]inch\s([^\(])/gi, '6 × 12 in (305 mm) $1'); txt.value = txt.value.replace(/seven\s12[\-\s]inch\s([^\(])/gi, '7 × 12 in (305 mm) $1'); txt.value = txt.value.replace(/eight\s12[\-\s]inch\s([^\(])/gi, '8 × 12 in (305 mm) $1'); txt.value = txt.value.replace(/(\d)\s[x×]\stwelve[\-\s]inch/gi, '$1 × 12 in (305 mm)'); txt.value = txt.value.replace(/(\d)\s[x×]\s12[\-\s]inch/gi, '$1 × 12 in (305 mm)'); txt.value = txt.value.replace(/\(305\s?mm\)\s?\(305\s?mm\)/gi, '(305 mm)'); //13 inch txt.value = txt.value.replace(/one\s13[\-\s]inch\s([^\(])/gi, '1 × 13 in (330 mm) $1'); txt.value = txt.value.replace(/two\s13[\-\s]inch\s([^\(])/gi, '2 × 13 in (330 mm) $1'); txt.value = txt.value.replace(/three\s13[\-\s]inch\s([^\(])/gi, '3 × 13 in (330 mm) $1'); txt.value = txt.value.replace(/four\s13[\-\s]inch\s([^\(])/gi, '4 × 13 in (330 mm) $1'); txt.value = txt.value.replace(/five\s13[\-\s]inch\s([^\(])/gi, '5 × 13 in (330 mm) $1'); txt.value = txt.value.replace(/six\s13[\-\s]inch\s([^\(])/gi, '6 × 13 in (330 mm) $1'); txt.value = txt.value.replace(/seven\s13[\-\s]inch\s([^\(])/gi, '7 × 13 in (330 mm) $1'); txt.value = txt.value.replace(/eight\s13[\-\s]inch\s([^\(])/gi, '8 × 13 in (330 mm) $1'); txt.value = txt.value.replace(/(\d)\s[x×]\sthirteen[\-\s]inch/gi, '$1 × 13 in (330 mm)'); txt.value = txt.value.replace(/(\d)\s[x×]\s13[\-\s]inch/gi, '$1 × 13 in (330 mm)'); txt.value = txt.value.replace(/\(330\s?mm\)\s?\(330\s?mm\)/gi, '(330 mm)'); //14 inch txt.value = txt.value.replace(/one\s14[\-\s]inch\s([^\(])/gi, '1 × 14 in (356 mm) $1'); txt.value = txt.value.replace(/two\s14[\-\s]inch\s([^\(])/gi, '2 × 14 in (356 mm) $1'); txt.value = txt.value.replace(/three\s14[\-\s]inch\s([^\(])/gi, '3 × 14 in (356 mm) $1'); txt.value = txt.value.replace(/four\s14[\-\s]inch\s([^\(])/gi, '4 × 14 in (356 mm) $1'); txt.value = txt.value.replace(/five\s14[\-\s]inch\s([^\(])/gi, '5 × 14 in (356 mm) $1'); txt.value = txt.value.replace(/six\s14[\-\s]inch\s([^\(])/gi, '6 × 14 in (356 mm) $1'); txt.value = txt.value.replace(/seven\s14[\-\s]inch\s([^\(])/gi, '7 × 14 in (356 mm) $1'); txt.value = txt.value.replace(/eight\s14[\-\s]inch\s([^\(])/gi, '14 × 14 in (356 mm) $1'); txt.value = txt.value.replace(/(\d)\s[x×]\s14[\-\s]inch/gi, '$1 × 14 in (356 mm)'); txt.value = txt.value.replace(/(\d)\s[x×]\sfourteen[\-\s]inch/gi, '$1 × 14 in (356 mm)'); txt.value = txt.value.replace(/\(356\s?mm\)\s?\(356\s?mm\)/gi, '(356 mm)'); //15 inch txt.value = txt.value.replace(/one\s15[\-\s]inch\s([^\(])/gi, '1 × 15 in (381 mm) $1'); txt.value = txt.value.replace(/two\s15[\-\s]inch\s([^\(])/gi, '2 × 15 in (381 mm) $1'); txt.value = txt.value.replace(/three\s15[\-\s]inch\s([^\(])/gi, '3 × 15 in (381 mm) $1'); txt.value = txt.value.replace(/four\s15[\-\s]inch\s([^\(])/gi, '4 × 15 in (381 mm) $1'); txt.value = txt.value.replace(/five\s15[\-\s]inch\s([^\(])/gi, '5 × 15 in (381 mm) $1'); txt.value = txt.value.replace(/six\s15[\-\s]inch\s([^\(])/gi, '6 × 15 in (381 mm) $1'); txt.value = txt.value.replace(/seven\s15[\-\s]inch\s([^\(])/gi, '7 × 15 in (381 mm) $1'); txt.value = txt.value.replace(/eight\s15[\-\s]inch\s([^\(])/gi, '15 × 15 in (381 mm) $1'); txt.value = txt.value.replace(/(\d)\s[x×]\s15[\-\s]inch/gi, '$1 × 15 in (381 mm)'); txt.value = txt.value.replace(/(\d)\s[x×]\sfifteen[\-\s]inch/gi, '$1 × 15 in (381 mm)'); txt.value = txt.value.replace(/\(381\s?mm\)\s?\(381\s?mm\)/gi, '(381 mm)'); //16 inch txt.value = txt.value.replace(/one\s16[\-\s]inch\s([^\(])/gi, '1 × 16 in (406 mm) $1'); txt.value = txt.value.replace(/two\s16[\-\s]inch\s([^\(])/gi, '2 × 16 in (406 mm) $1'); txt.value = txt.value.replace(/three\s16[\-\s]inch\s([^\(])/gi, '3 × 16 in (406 mm) $1'); txt.value = txt.value.replace(/four\s16[\-\s]inch\s([^\(])/gi, '4 × 16 in (406 mm) $1'); txt.value = txt.value.replace(/five\s16[\-\s]inch\s([^\(])/gi, '5 × 16 in (406 mm) $1'); txt.value = txt.value.replace(/six\s16[\-\s]inch\s([^\(])/gi, '6 × 16 in (406 mm) $1'); txt.value = txt.value.replace(/seven\s16[\-\s]inch\s([^\(])/gi, '7 × 16 in (406 mm) $1'); txt.value = txt.value.replace(/eight\s16[\-\s]inch\s([^\(])/gi, '16 × 16 in (406 mm) $1'); txt.value = txt.value.replace(/(\d)\s[x×]\s16[\-\s]inch/gi, '$1 × 16 in (406 mm)'); txt.value = txt.value.replace(/(\d)\s[x×]\ssixteen[\-\s]inch/gi, '$1 × 16 in (406 mm)'); txt.value = txt.value.replace(/\(406\s?mm\)\s?\(406\s?mm\)/gi, '(406 mm)'); //18 inch txt.value = txt.value.replace(/one\s18[\-\s]inch\s([^\(])/gi, '1 × 18 in (457 mm) $1'); txt.value = txt.value.replace(/two\s18[\-\s]inch\s([^\(])/gi, '2 × 18 in (457 mm) $1'); txt.value = txt.value.replace(/three\s18[\-\s]inch\s([^\(])/gi, '3 × 18 in (457 mm) $1'); txt.value = txt.value.replace(/four\s18[\-\s]inch\s([^\(])/gi, '4 × 18 in (457 mm) $1'); txt.value = txt.value.replace(/five\s18[\-\s]inch\s([^\(])/gi, '5 × 18 in (457 mm) $1'); txt.value = txt.value.replace(/six\s18[\-\s]inch\s([^\(])/gi, '6 × 18 in (457 mm) $1'); txt.value = txt.value.replace(/seven\s18[\-\s]inch\s([^\(])/gi, '7 × 18 in (457 mm) $1'); txt.value = txt.value.replace(/eight\s18[\-\s]inch\s([^\(])/gi, '18 × 18 in (457 mm) $1'); txt.value = txt.value.replace(/(\d)\s[x×]\s18[\-\s]inch/gi, '$1 × 18 in (457 mm)'); txt.value = txt.value.replace(/(\d)\s[x×]\seighteen[\-\s]inch/gi, '$1 × 18 in (457 mm)'); txt.value = txt.value.replace(/\(457\s?mm\)\s?\(457\s?mm\)/gi, '(457 mm)'); //21 inch txt.value = txt.value.replace(/one\s21[\-\s]inch\s([^\(])/gi, '1 × 21 in (533 mm) $1'); txt.value = txt.value.replace(/two\s21[\-\s]inch\s([^\(])/gi, '2 × 21 in (533 mm) $1'); txt.value = txt.value.replace(/three\s21[\-\s]inch\s([^\(])/gi, '3 × 21 in (533 mm) $1'); txt.value = txt.value.replace(/four\s21[\-\s]inch\s([^\(])/gi, '4 × 21 in (533 mm) $1'); txt.value = txt.value.replace(/five\s21[\-\s]inch\s([^\(])/gi, '5 × 21 in (533 mm) $1'); txt.value = txt.value.replace(/six\s21[\-\s]inch\s([^\(])/gi, '6 × 21 in (533 mm) $1'); txt.value = txt.value.replace(/seven\s21[\-\s]inch\s([^\(])/gi, '7 × 21 in (533 mm) $1'); txt.value = txt.value.replace(/eight\s21[\-\s]inch\s([^\(])/gi, '8 × 21 in (533 mm) $1'); txt.value = txt.value.replace(/(\d)\s[x×]\stwenty[\-\s]one[\-\s]inch/gi, '$1 × 21 in (533 mm)'); txt.value = txt.value.replace(/(\d)\s[x×]\s21[\-\s]inch/gi, '$1 × 21 in (533 mm)'); txt.value = txt.value.replace(/\(533\s?mm\)\s?\(533\s?mm\)/gi, '(533 mm)'); // Convert degree symbols into ° symbol, ensure preceding space txt.value = txt.value.replace(/°/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 //txt.value = txt.value.replace(/\[\[(celsius)\]\]/gi, '$1'); //txt.value = txt.value.replace(/\[\[celsius\|([^\]]{1,30})\]\]/gi, '$1'); //Fahrenheit //txt.value = txt.value.replace(/\[\[(Fahrenheit)\]\]/gi, '$1'); // txt.value = txt.value.replace(/\[\[Fahrenheit\|([^\]]{1,30})\]\]/gi, '$1'); //Celsius or Fahrenheit txt.value = txt.value.replace(/°\s([CF])/g, '°$1'); txt.value = txt.value.replace(/°\s?(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\.?\s?([CF])/gi, '°$1'); txt.value = txt.value.replace(/degrees?\s([CF])(\W)/gi, '°$1$2'); txt.value = txt.value.replace(/(\d)\s?° ([CF])/g, '$1 °$2'); // Convert &sup to superscript txt.value = txt.value.replace(/²/g, '²'); txt.value = txt.value.replace(/³/g, '³'); // Convert micro symbol to actual micro symbol, make sure it's spaced txt.value = txt.value.replace(/(\d)\s?(μ|μ|µ)(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 //txt.value = txt.value.replace(/\[\[(metres?)\]\]/gi, '$1'); //txt.value = txt.value.replace(/\[\[(meters?)\]\]/gi, '$1'); //txt.value = txt.value.replace(/\[\[metres?\|([^\]]{1,30})\]\]/gi, '$1'); //space before 'm' only when lower case txt.value = txt.value.replace(/(\d)\s?m(\W)/g, '$1 m$2'); txt.value = txt.value.replace(/(\d)\-m(\W)/g, '$1 m$2'); txt.value = txt.value.replace(/(\d)\s?sq\.?\s?m(\W)/gi, '$1 m²$2'); txt.value = txt.value.replace(/(\d)\-?sq\-?m(\W)/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} )meters?(( |\s{1,3})\()/gi, '$1m$2'); txt.value = txt.value.replace(/([\|\=\>][\s\d\.]{1,9} )metres?(( |\s{1,3})\()/gi, '$1m$2'); // millimetre //txt.value = txt.value.replace(/\[\[(mm)\]\]/gi, '$1'); //txt.value = txt.value.replace(/\[\[(millimetres?)\]\]/gi, '$1'); //txt.value = txt.value.replace(/\[\[(millimeters?)\]\]/gi, '$1'); //txt.value = txt.value.replace(/\[\[millimetres?\|([^\]]{1,30})\]\]/gi, '$1'); //txt.value = txt.value.replace(/\[\[millimeters?\|([^\]]{1,30})\]\]/gi, '$1'); 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'); // centimetre //txt.value = txt.value.replace(/\[\[(cm)\]\]/gi, '$1'); //txt.value = txt.value.replace(/\[\[(centimetres?)\]\]/gi, '$1'); //txt.value = txt.value.replace(/\[\[(centimeters?)\]\]/gi, '$1'); //txt.value = txt.value.replace(/\[\[centimetres?\|([^\]]{1,30})\]\]/gi, '$1'); //txt.value = txt.value.replace(/\[\[centimeters?\|([^\]]{1,30})\]\]/gi, '$1'); // kilometre //txt.value = txt.value.replace(/\[\[(km)\]\]/gi, '$1'); //txt.value = txt.value.replace(/\[\[(kilometres?)\]\]/gi, '$1'); //txt.value = txt.value.replace(/\[\[(kilometers?)\]\]/gi, '$1'); //txt.value = txt.value.replace(/\[\[kilometres?\|([^\]]{1,30})\]\]/gi, '$1'); //txt.value = txt.value.replace(/\[\[kilometers?\|([^\]]{1,30})\]\]/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) kms?(\W)/gi, '$1 km$2'); //square kilometre //txt.value = txt.value.replace(/\[\[square kilometres?\|([^\]]{1,30})\]\]/gi, '$1'); txt.value = txt.value.replace(/(\d)\s?sq\.?\s?kms?/gi, '$1 km²'); txt.value = txt.value.replace(/sq\.?\s?kms?/gi, 'km²'); // 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(/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'); // cubic centimetre txt.value = txt.value.replace(/(\d)\s?cm(\W)/gi, '$1 cm$2'); txt.value = txt.value.replace(/(\d)\s?cc(\W)/gi, '$1 cc$2'); txt.value = txt.value.replace(/(\d)\-cc(\W)/gi, '$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?m\/second/gi, '$1 m/s'); 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'); txt.value = txt.value.replace(/\/hr(\W)/gi, '/h$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(/(kilogram)me/gi, '$1'); txt.value = txt.value.replace(/(\W)(gram)mes?(\W)/gi, '$1$2$3'); //txt.value = txt.value.replace(/\[\[(grams?)\]\]/gi, '$1'); //txt.value = txt.value.replace(/\[\[grams?\|([^\]]{1,30})\]\]/gi, '$1'); //txt.value = txt.value.replace(/\[\[(kg)\]\]/gi, '$1'); //txt.value = txt.value.replace(/\[\[(kilograms?)\]\]/gi, '$1'); //txt.value = txt.value.replace(/\[\[kilograms?\|([^\]]{1,30})\]\]/gi, '$1'); 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'); // newton metre //txt.value = txt.value.replace(/(\W)N[-.·•\/]m(\W)/gi, '$1N·m$2'); 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?(Ω|ohm|Ohm)s?(\W)/g, '$1 $2Ω$4'); // pound weight //txt.value = txt.value.replace(/(\d)\s?(\[\[lbs?\]\])/gi, '$1 lb'); //txt.value = txt.value.replace(/\[\[\pound\s\(mass\)\|([^\]]{1,30})\]\]/gi, '$1'); 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) lbs?/gi, '$1 lb'); txt.value = txt.value.replace(/(\d)\slb.\)/gi, '$1 lb)'); //inch //txt.value = txt.value.replace(/\[\[(inch)\]\]/gi, '$1'); //txt.value = txt.value.replace(/\[\[(inches)\]\]/gi, '$1'); //txt.value = txt.value.replace(/\[\[inch\|([^\]]{1,30})\]\]/gi, '$1'); //txt.value = txt.value.replace(/\[\[inches\|([^\]]{1,30})\]\]/gi, '$1'); //foot //txt.value = txt.value.replace(/\[\[foot\s\(unit\sof\slength\)\|([^\]]{1,30})\]\]/gi, '$1'); 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(/ feet\)/gi, ' ft)'); txt.value = txt.value.replace(/(\|[\s\d\.]{1,9})feet(\s{1,3}\()/gi, '$1ft$2'); // square foot txt.value = txt.value.replace(/sq\.?\s?ft/gi, 'sq ft'); // foot and inch //txt.value = txt.value.replace(/([^;°h]{1,4})(\d{1,4})\s?['’]\s?(\d{1,3})\s?["”]([^NESW])/g, '$1$2 ft $3 in$4'); 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) yds(\W)/gi, '$1 yd$2'); txt.value = txt.value.replace(/sq\.?\s?yds?/gi, 'sq yd'); txt.value = txt.value.replace(/yd\.\)/gi, 'yd)'); // mile and mile per hour //txt.value = txt.value.replace(/\[\[miles?\|([^\]]{1,30})\]\]/gi, '$1'); //txt.value = txt.value.replace(/\[\[(miles?)\]\]/gi, '$1'); txt.value = txt.value.replace(/m\.p\.h\.(\W)/g, 'mph$1'); txt.value = txt.value.replace(/(\W)mph(\W)/gi, '$1mph$2'); txt.value = txt.value.replace(/(\d)\s?mph/gi, '$1 mph'); txt.value = txt.value.replace(/(\d)\-mph/gi, '$1 mph'); // square mile txt.value = txt.value.replace(/sq\.?\s?mi/gi, 'sq mi'); // 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'); //the next two suspended until solution is found for wing loading (i.e. pounds per square foot) //txt.value = txt.value.replace(/lb[fs][ -.•\/]ft/gi, 'ft·lbf'); //txt.value = txt.value.replace(/lb[ -.•\/]ft/gi, 'ft·lbf'); // Give digital value a percent symbol '%' instead of word txt.value = txt.value.replace(/(\d)\s?per ?cent([^aei])/gi, '$1%$2'); txt.value = txt.value.replace(/(\d)\-per ?cent([^aei])/gi, '$1%$2'); // knot txt.value = txt.value.replace(/(\d)\s?kts(\W)/gi, '$1 knots$2'); txt.value = txt.value.replace(/(\d)\s?knt(\W)/gi, '$1 knots$2'); // horsepower txt.value = txt.value.replace(/(\d)\s?hp(\W)/gi, '$1 hp$2'); txt.value = txt.value.replace(/(\d)\s?bhp/gi, '$1 bhp'); txt.value = txt.value.replace(/(\d)\s?shp/gi, '$1 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)\-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(/([KkMmGg])(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) bps/gi, '$1 bit/s'); txt.value = txt.value.replace(/bits?\/sec(\W)/gi, 'bit/s$1'); // bytes per second txt.value = txt.value.replace(/([KkMmGg])(Bps|bytes?\/s)/g, ' $1B/s'); txt.value = txt.value.replace(/bytes?\/s(\W)/gi, 'B/s$1'); // capitalization of prefix with bits and bytes txt.value = txt.value.replace(/K(bit|B)\/s/g, 'k$1/s'); txt.value = txt.value.replace(/m(bit|B)\/s/g, 'M$1/s'); txt.value = txt.value.replace(/g(bit|B)\/s/g, 'G$1/s'); // space with bits and bytes txt.value = txt.value.replace(/(\d)\s?(k|M|G)(bit|B)/g, '$1 $2$3'); // Common error with bits and bytes txt.value = txt.value.replace(/mibi(bit|byte)/g, 'mebi$1'); //Remove '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'); // century without AD,BC etc 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'); // century with AD,BC etc 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'); txt.value = txt.value.replace(/(\d(?:st|nd|rd|th))[ \-]Century/gi, '$1 century'); // piped decades and years txt.value = txt.value.replace(/\[\[(\d{1,4}\'?s)\]\]/gi, '$1'); txt.value = txt.value.replace(/\[\[(\d{1,4}s? (?:AD|BC|CE|BCE))\]\]/gi, '$1'); txt.value = txt.value.replace(/\[\[\d{1,4}s? (?:AD|BC|CE|BCE)\|(\d{1,4})\]\]/gi, '$1'); txt.value = txt.value.replace(/\[\[\d{1,4}s? (?:AD|BC|CE|BCE)\|(\d{1,4}s? (?:AD|BC|CE|BCE))\]\]/gi, '$1'); txt.value = txt.value.replace(/\[\[\d{1,4}s?\|(\d{1,4}s? (?:AD|BC|CE|BCE))\]\]/gi, '$1'); txt.value = txt.value.replace(/\[\[\d{1,4}s?\|(\d{1,2}s?)\]\]/gi, '$1'); // months txt.value = txt.value.replace(/\[\[(January|February|March|April|May|June|July|August|September|October|November|December)\]\]/gi, '$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+year txt.value = txt.value.replace(/\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December) \d{3,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) \d{1,2}\|((?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{1,2})\]\]/gi, '$1'); // 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'); // 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?)\]\]/gi, '$1'); txt.value = txt.value.replace(/\[\[Tuesdays?\|(Tuesdays?)\]\]/gi, '$1'); txt.value = txt.value.replace(/\[\[Wednesdays?\|(Wednesdays?)\]\]/gi, '$1'); txt.value = txt.value.replace(/\[\[Thursdays?\|(Thursdays?)\]\]/gi, '$1'); txt.value = txt.value.replace(/\[\[Fridays?\|(Fridays?)\]\]/gi, '$1'); txt.value = txt.value.replace(/\[\[Saturdays?\|(Saturdays?)\]\]/gi, '$1'); txt.value = txt.value.replace(/\[\[Sundays?\|(Sundays?)\]\]/gi, '$1'); //4 digit years piped into 2 txt.value = txt.value.replace(/\[\[\d{1,4}\|(\d{1,2})\]\]/gi, '$1'); //year: examine characters in link on left for date, examine characters in link on right for date txt.value = txt.value.replace(/((?:[^yhletramub\s]..|[^rcianlse\d\s].|[^yhletr\d])\]\]\s?,?\-?\s?)\[\[(\d{1,4})\]\](\s?,?\-?\s?\[\[(?:[^jfmasond\d]|.[^aepuco\d\s]|..[^jfmasondbrylgptvc \s\-]))/gi, '$1$2$3'); //year pair: examine characters in link on left for date, examine characters in link on right for date txt.value = txt.value.replace(/((?:[^yhletramub\s]..|[^rcianlse\d\s].|[^yhletr\d])\]\]\s?,?\-?\s?)\[\[(\d{1,4})\]\](.?.?.?.?.?.?)\[\[(\d{1,4})\]\](\s?,?\-?\s?\[\[(?:[^jfmasond\d]|.[^aepuco\d\s]|..[^jfmasondbrylgptvc\s\-]))/gi, '$1$2$3$4$5'); //year: examine characters in link on left for date, avoid links on right txt.value = txt.value.replace(/((?:[^yhletramub\s]..|[^rcianlse\d\s].|[^yhletr\d])\]\]\s?,?\-?\s?)\[\[(\d{1,4})\]\]([^\[]{4})/gi, '$1$2$3'); //year pair: examine characters in link on left for date, avoid links on right txt.value = txt.value.replace(/((?:[^yhletramub\s]..|[^rcianlse\d\s].|[^yhletr\d])\]\]\s?,?\-?\s?)\[\[(\d{1,4})\]\](.?.?.?.?.?.?)\[\[(\d{1,4})\]\]([^\[]{4})/gi, '$1$2$3$4$5'); //year: check for line-ends, text on left, avoid links on right. Run twice to deal better with lists. txt.value = txt.value.replace(/([\w\(\);=:.'\*\|\&]\s?,?\-?\s?|\n)\[\[(\d{1,4})\]\]([^\[]{4}|\n)/gi, '$1$2$3'); txt.value = txt.value.replace(/([\w\(\);=:.'\*\|\&]\s?,?\-?\s?|\n)\[\[(\d{1,4})\]\]([^\[]{4}|\n)/gi, '$1$2$3'); //year pair: check for line-ends, text on left, avoid links on right txt.value = txt.value.replace(/([\w\(\);=:.'\*\|\&]\s?,?\-?\s?)\[\[(\d{1,4})\]\](.?.?.?.?.?.?)\[\[(\d{1,4})\]\]([^\[]{4}|\n)/gi, '$1$2$3$4$5'); //year: avoid links on left, examine characters in link on right for date txt.value = txt.value.replace(/([^\]]{4})\[\[(\d{1,4})\]\](\s?,?\-?\s?\[\[(?:[^jfmasond\d]|.[^aepuco\d\s]|..[^jfmasondbrylgptvc \s\-]))/gi, '$1$2$3'); //year pair: avoid links on left, examine characters in link on right for date txt.value = txt.value.replace(/([^\]]{4})\[\[(\d{1,4})\]\](.?.?.?.?.?.?)\[\[(\d{1,4})\]\](\s?,?\-?\s?\[\[(?:[^jfmasond\d]|.[^aepuco\d\s]|..[^jfmasondbrylgptvc \s\-]))/gi, '$1$2$3$4$5'); //year:avoid links on left, text on right txt.value = txt.value.replace(/([^\]]{4})\[\[(\d{1,4})\]\](\s?,?\-?\s?[\w\(\);=:.'\*\|\&])/gi, '$1$2$3'); //year pair: avoid links on left, text on right txt.value = txt.value.replace(/([^\]]{4})\[\[(\d{1,4})\]\](.?.?.?.?.?.?)\[\[(\d{1,4})\]\](\s?,?\-?\s?[\w\(\);=:.'\*\|\&])/gi, '$1$2$3$4$5'); //year:text on left, text on right txt.value = txt.value.replace(/([\w\(\);=:.'\*\|\&]\s?,?\-?\s?)\[\[(\d{1,4})\]\](\s?,?\-?\s?[\w\(\);=:.'\*\|\&])/gi, '$1$2$3'); //year pair: avoid links on left, text on right txt.value = txt.value.replace(/([\w\(\);=:.'\*\|\&]\s?,?\-?\s?)\[\[(\d{1,4})\]\](.?.?.?.?.?.?)\[\[(\d{1,4})\]\](\s?,?\-?\s?[\w\(\);=:.'\*\|\&])/gi, '$1$2$3$4$5'); //year:avoid links on left, hyphen but no digits (to avoid ISO date) in link on right. Currently suspended because it isn't fully tested. //txt.value = txt.value.replace(/([^\]]{4})\[\[(\d{1,4})\]\](\s?,?\-?\s?\[\[[^\d])/gi, '$1$2$3'); //year:avoid links on both sides txt.value = txt.value.replace(/([^\]]{4})\[\[(\d{1,4})\]\]([^\[]{4})/gi, '$1$2$3'); //year pair: avoid links on both sides txt.value = txt.value.replace(/([^\]]{4})\[\[(\d{1,4})\]\](.?.?.?.?.?.?)\[\[(\d{1,4})\]\]([^\[]{4})/gi, '$1$2$3$4$5'); //'present' txt.value = txt.value.replace(/\[\[Present \(time\)\|(Present)\]\]/gi, '$1'); //Eliminate 'surprise links' also known as 'easter egg links' txt.value = txt.value.replace(/\[\[\d{1,4}s?\sin\s[^\|]{1,30}\|(\d{1,4}s?)\]\]/gi, '$1'); // Add a tag to the summary box var txt = document.editform.wpSummary; var summary = "units &/or links"; 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() } addOnloadHook(function () { if(document.forms.editform) { addLink('p-cactions', 'javascript:formatgeneral()', 'general', 'ca-unitfixer', 'Fixes some unit formatting', '', ''); } });