User:Frietjes/autoclean.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.
// <nowiki>
jQuery(document).ready(function($) {
 var myContent = document.getElementsByName('wpTextbox1')[0];
 if( document.getElementsByClassName("infobox").length > 0 ) {
 document.getElementsByClassName("infobox")[0].setAttribute('id', 'infobox');
 if( document.getElementsByClassName("mw-revision").length > 0) {
 document.location.hash = "#infobox";
 }
 }
 if(mw.config.get("wgTitle").toLowerCase() == "templates for discussion/noincluded tags") {
 var litags = document.getElementsByTagName("li");
 for (i = 0; i < litags.length; i++) {
 if (litags[i].innerHTML) {
 var txt = litags[i].innerHTML;
 txt = txt.replace(/&nbsp;\(.*/gi, '');
 litags[i].innerHTML = txt;
 } else {
 alert(i);
 }
 }
 }
 function wpCleanNavbox()
 {
 var config = mw.config.get(['wgNamespaceNumber', 'wgTitle', 'wgUserGroups', 'skin']);

 var lt = '';
 var oldtext = myContent.value;
 var count = 0;
 var mysummary = '';

 myContent.value = myContent.value.replace(/(\[\[Category:[^\[\]]*)(<noinclude>)([^\[\]]*)(<\/noinclude>)(\]\])/gi, '<includeonly>$1$5</includeonly>$2$1$3$5$4');
 myContent.value = myContent.value.replace(/[\r\n][\t ]*<\/noinclude[\t ]*>([\t \r\n]*)<noinclude>[\t ]*([\r\n])/gi, '$1$2');
 myContent.value = myContent.value.replace(/<\/noinclude[\t ]*>([\t \r\n]*)<[\t ]*noinclude>/gi, '$1');
 if(myContent.value != oldtext) {
 var editsummary = document.getElementsByName('wpSummary')[0];
 editsummary.value = 'remove redundant </noinclude' + '><noinclude' + '>';
 }
 oldtext = myContent.value;
 myContent.value = myContent.value.replace(/(\{\{)[ ]*(#ifeq:[^\|{}]*\|[ ]*Category)/gi, '$1subst:$2');
 if(myContent.value != oldtext) {
 var editsummary = document.getElementsByName('wpSummary')[0];
 editsummary.value = 'clean up after bot banner expansion';
 }
 myContent.value = myContent.value.replace(/Cite url=https:\/\/www.ccainstitute.org/gi, 'Cite web|title=Congressional Coalition on Adoption Institute|url=https://www.ccainstitute.org');
 myContent.value = myContent.value.replace(/\{\{([^{}\|#]*(?:[0-9][0-9][0-9][0-9][^{}#\|]*election|election[^{}#\|]*[0-9][0-9][0-9][0-9])[^{}\|]*)\}\}/gi, '{'+'{subst:((}'+'}{'+'{subst:#invoke:string|replace|{'+'{subst:#invoke:redirect|main|Template:$1}'+'}|Template:'+'}'+'}{'+'{subst:))}'+'}');
 myContent.value = myContent.value.replace(/\{\{([^{}\|#]*(?:[0-9][0-9][0-9][0-9][^{}#\|]*election|election[^{}#\|]*[0-9][0-9][0-9][0-9])[^{}\|]*)\|/gi, '{'+'{subst:((}'+'}{'+'{subst:#invoke:string|replace|{'+'{subst:#invoke:redirect|main|Template:$1}'+'}|Template:'+'}'+'}|');
 myContent.value = myContent.value.replace(/(\{\{)#if:(?:trim|1)\|(\{\{#(?:\{\{[^{}]*\}\}|[^{}])*\}\}\}\})/g, '$1P1|1=$2'); 
 myContent.value = myContent.value.replace(/\|[ ]*liststyle[ ]*=[ ]*font\-style[ ]*:[ ]*italic[; ]*[\r\n]((?:\|[ ]*group[0-9]+[ ]*=[^\r\n]*[\r\n]|[\r\n\t ])*\|[ ]*list[0-9]+[ ]*=[ ]*[\r\n]*\*[ ]*)(\[\[[^\[\]]*\]\])/gi, '$1\'\'$2\'\'<!-- GM ITALIC -->');
 myContent.value = myContent.value.replace(/\{\|[ ]*style[ ]*=[ ]*"width:100[^\r\n]*[\r\n](?:\|\-[^\r\n]*[\r\n]|)\|[ ]*(?:style="width:|width[ ]*=)["0-9%';]*[ ]*\|[ ]*[\r\n]('''[^\r\n]*)([\r\n])/gi, '$1$2{'+'{colbegin|colwidth=22em}'+'}<!--' + ' IN COL -->$2');
 while( lt != myContent.value ) {
 lt = myContent.value;
 myContent.value = myContent.value.replace(/(<!--[ ]*IN COL[ ]*-->)([\r\n]\*[^\r\n]*)/gi, '$2$1');
 myContent.value = myContent.value.replace(/(<!--[ ]*IN COL[ ]*-->)([\r\n])(?:[\t ]*[\r\n]|)(?:\|[ ]*(?:style="width|width)[^\r\n]*|[\t ]*|)([\r\n]'''[^\r\n]*)/gi, '$2{' + '{colend}' + '}$3$2{' + '{colbegin|colwidth=22em}' + '}$1');
 myContent.value = myContent.value.replace(/<!--[ ]*IN COL[ ]*-->([\r\n])(?:[\t ]*[\r\n]|)(?:\|[ ]*(?:style="width|width)[^\r\n]*[\r\n]|)\|\}/gi, '$1{' + '{colend}' + '}');
 myContent.value = myContent.value.replace(/([^e]\||1[ ]*=|[^\(:]\}\})[\t ]*(\{\{subst:)/gi, '$1\n$2');
 myContent.value = myContent.value.replace(/(<!--[ ]*GM ITALIC[ ]*-->)((?:\([^\(\)]*\)|[\t ])*(?:\|[ ]*group[0-9]+[ ]*=[^\r\n]*[\r\n]|[\r\n\t ])*[\r\n]\*[\t ]*)(\[\[[^\[\]]*\]\])/gi, '$2\'\'$3\'\'$1');
 myContent.value = myContent.value.replace(/(<!--[ ]*GM ITALIC[ ]*-->)((?:\([^\(\)]*\)|[\t ])*(?:\|[ ]*group[0-9]+[ ]*=[^\r\n]*[\r\n]|[\r\n\t ])*[\r\n]\*[\t ]*)([A-Z0-9a-z][^\(\)\r\n]*[A-Za-z0-9])/gi, '$2\'\'$3\'\'$1');
 myContent.value = myContent.value.replace(/<!--[ ]*GM ITALIC[ ]*-->((?:\([^\(\)]*\)|[\t ])*[\r\n]*[\t ]*\}\})/gi, '$1');
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*([Ii]nfobox)[_ ]+NAIA[_ ]+[Bb]asketball[_ ]+[Tt]ournament[\t \|]*([\r\n])/g, '$1$2 college basketball tournament$3| Type=NAIA<!-- GM CB -->$3');
 myContent.value = myContent.value.replace(/(<!-- GM CB -->)[\t ]*([\r\n]\|[\t ]*)Coach([\t ]*=[^\r\n]*)/gi, '$2COTY$3$1');
 myContent.value = myContent.value.replace(/(<!-- GM CB -->)[\t ]*([\r\n]\|[\t ]*)Coach(School[\t ]*=[^\r\n]*)/gi, '$2COTY$3$1');
 myContent.value = myContent.value.replace(/(<!-- GM CB -->)[\t ]*([\r\n]\|[\t ]*)Player([\t ]*=[^\r\n]*)/gi, '$2POTY$3$1');
 myContent.value = myContent.value.replace(/(<!-- GM CB -->)[\t ]*([\r\n]\|[\t ]*)Player(School[\t ]*=[^\r\n]*)/gi, '$2POTY$3$1');
 myContent.value = myContent.value.replace(/(<!-- GM CB -->)[\t ]*([\r\n]\|[\t ]*[^\r\n]*)/gi, '$2$1');
 myContent.value = myContent.value.replace(/(<!-- GM CB -->)[\t ]*([\r\n]\}\})/gi, '$2');
 }
 lt='';
 
 myContent.value = myContent.value.replace(/[Ww]ayback[\t ]*\|[\t ]*url[\t ]*=[\t ]*([^\r\n\|\{\} ]*)[\t ]*\|[\t ]*date[\t ]*=[\t ]*([0-9]+)[\t ]*(\||\}\})/g, 'webarchive|url=https://web.archive.org/web/$2/$1$3');
 myContent.value = myContent.value.replace(/[Ww]eb[_ ]*[Aa]rchive?[\t ]*\|([^{}]*\||)[\t ]*url[\t ]*=[\t ]*([^\{\}]*?)[\t ]*\|[\t ]*wayback[\t ]*=[\t ]*([0-9]+)[\t ]*(\||\}\})/gi, 'webarchive|$1url=https://web.archive.org/web/$3/$2$4');
 myContent.value = myContent.value.replace(/[Ww]eb[_ ]*[Aa]rchive?[\t ]*\|([^{}]*\||)[\t ]*url[\t ]*=[\t ]*([^\{\}]*?)[\t ]*\|[\t ]*archive-is[\t ]*=[\t ]*([0-9]+)[\t ]*(\||\}\})/gi, 'webarchive|$1url=https://archive.today/$3/$2$4');
 myContent.value = myContent.value.replace(/[Ww]eb[_ ]*[Aa]rchive?[\t ]*\|([^{}]*\||)text[\t ]*=/gi, 'webarchive|$1title=');
 myContent.value = myContent.value.replace(/(\{\{[_\t ]*web[_ ]*archiv[^{}]*\|)[\t ]*text[\t ]*=/gi, '$1title=');
 
 myContent.value = myContent.value.replace(/<div class[^<>]*tright[^<>]*>[\t \r\n]*(.*?\|border\|)(.*?)<\/div>/gi, '$1right|$2');
 myContent.value = myContent.value.replace(/<div class[^<>]*tright[^<>]*>[\t \r\n]*(.*?)<\/div>/gi, '{'+'{stack|$1}'+'}');
 myContent.value = myContent.value.replace(/[\t ]*<!--[^<>]*AWB[^<>]*-->[\t ]*[\r\n]*/gi, '');
 myContent.value = myContent.value.replace(/(\{\{)(coordinate[\t ]*\|)/gi, '$1subst:$2');
 myContent.value = myContent.value.replace(/(\{\{Portal bar[^{}]*\}\})[\t ]*([\r\n])[\t ]*[\r\n]/gi, '$1$2');
 myContent.value = myContent.value.replace(/([A-Z])[_ ]+Standings[_ ]+Start/gi, '$1 standings start');
 myContent.value = myContent.value.replace(/([A-Z])[_ ]+Standings[_ ]+Entry/gi, '$1 standings entry');
 myContent.value = myContent.value.replace(/([A-Z])[_ ]+Standings[_ ]+End/gi, '$1 standings end');
 myContent.value = myContent.value.replace(/(?:\|\-[\t ]*[\r\n]|)\|[^\r\n]*CCC[^\r\n]*\|[' ]*(East|West)[' ]*([\r\n])(?:\|\-[\t ]*[\r\n]|)/gi, '{' + '{CBB standings entry|division-name={' + '{center|$1}' + '}' + '}' + '}$2');
 myContent.value = myContent.value.replace(/(\{\{[A-Z]+[_ ]*standings[_ ]*end[^{}]*)\|[ ]*(<ref[^<>]*>[^<>]*<\/ref>)[ ]*(\|[^{}]*\}\}<noinclude>[ ]*[\r\n]*)/g, '$1$3$2\n');
 
 myContent.value = myContent.value.replace(/(\[\[Category:[^\[\]]*\]\][\t ]*[\r\n])[\t ]*([\r\n])(\[\[Category[^\r\n]*)/gi, '$1$3$2');
 myContent.value = myContent.value.replace(/([\r\n])(\[\[Category:[^\[\]]*\]\])[\t ]*(\[\[Category[^\r\n]*)/gi, '$1$2$1$3');
 myContent.value = myContent.value.replace(/(\[\[Category:[^\[\]]*\]\])[\t ]*([\r\n])(\[\[Category[^\r\n]*)(<\/noinclude>)/gi, '$1$2$3$2$4');
 myContent.value = myContent.value.replace(/<[^<>]*br[^<>]*>[ ]*(\{\{Radio[_ ]*Formats)/gi, '$1');
 myContent.value = myContent.value.replace(/border[ ]*=["' ]*[0-9]*['" ]*([^\r\n]*wikitable)/gi, '$1');
 myContent.value = myContent.value.replace(/([\r\n]\|\})[\t ]*([\r\n][\t ]*[\r\n]*[\t ]*[\r\n]*)(<noinclude>)/g, '$1$3$2');
 myContent.value = myContent.value.replace(/([\r\n]![^\r\n\|]*\|)[' ]*(\[\[[^\[\]]*\]\])[' ]*(\{\{)navbar\|([^{}\|]*)(?:\|[^{}]*|)(\}\})/gi, '$1 $3navbar-header|$2|$4$5');
 myContent.value = myContent.value.replace(/([\r\n]![^\r\n]*\{\{[Nn]av[^{}]*)'''/gi, '$1');
 myContent.value = myContent.value.replace(/([\r\n]![^\r\n]*\{\{[Nn]av[^{}]*)'''/gi, '$1');
 myContent.value = myContent.value.replace(/(\{\|[ ]*class="wikitable")[ ]*width[^\r\n]*[ ]*(style=")([^\r\n]*(?:[\r\n]\|\-|)[\t ]*[\r\n]![\t ]*[^\r\n]*navbar\-header)/g, '$1 $2width:50em;$3');
 myContent.value = myContent.value.replace(/(\{\|[ ]*class="wikitable")[ ]*width[^\r\n]*[ ]*(style=")([^\r\n]*(?:[\r\n]\|\-|)[\r\n]![^\r\n]*[\r\n]![^\r\n]*colspan[^\r\n]*navbar\-header)/g, '$1 $2width:35em;$3');
 myContent.value = myContent.value.replace(/(\{\{navbar\-header\|(?:\[\[[^\[\]]*\]\]|[^\[\]\|])*\|)[^{}\|\[\]]*(\}\})/gi, '$1{'+'{subst:#invoke:string|replace|'+'{'+'{subst:#invoke:string|replace|'+'{'+'{subst:PAGENAME}'+'}|&#39;|\'}'+'}|&#38;|&}'+'}$2');
 
 myContent.value = myContent.value.replace(/(\|[ ]*(?:above|below|list[0-9]*)style[ ]*=(?:\{\{[^{}]*\}\}|[^{}\|\[\]])*)[\t ]+width[\t ]*:[\t ]*100%[\t; ]*/g, '$1');
 myContent.value = myContent.value.replace(/(\|[ ]*(?:above|below|list[0-9]*)style[ ]*=(?:\{\{[^{}]*\}\}|[^{}\|\[\]])*)width[\t ]*:[\t ]*100%[\t; ]*/g, '$1');
 
 myContent.value = myContent.value.replace(/(\{\{#invoke:)[Tt]ranscludable[_ ]+section[_ ]*\|[ ]*main[ ]*(\|[ ]*section[ ]*=[^\|\r\n]*)\|[ ]*text[ ]*=[\t \r\n]*\{\{[_ ]*([Ff]ootball[_ ]box)[ ]*((?:[\r\n]|\|)(?:\{\{[^{}]*\}\}|[^{}])*\}\})[\t \r\n]*\}\}/g, '$1$3|main$2$4');
 
 myContent.value = myContent.value.replace(/(\|[ ]*update[ ]*=[^\r\n]*)([\r\n])(\|[ ]*team)([2-9]|[12][0-9])([ ]*=)/g, '$1$2|highest_pos = $4$2$3$4$5');
 for(var i=0; i<4; i++) {
 myContent.value = myContent.value.replace(/(\{\{winners(?:\{\{[^{}]*\}\}|[^{}])*)'''/gi, '$1');
 }
 myContent.value = myContent.value.replace(/(\{\{winners(?:\{\{[^{}]*\}\}|[^{}])*)<br[^<>]*>((?:\{\{[^{}]*\}\}|[^{}])*) title[ ]*(\}\})/gi, '$1|$2$3');
 
 if(myContent.value.search(/Infobox Indian state legislative assembly/i) >= 0) {
 myContent.value = myContent.value.replace(/[\t ]+/g, ' ');
 myContent.value = myContent.value.replace(/(\{\{Election box[^{}]*[^\t ])[\t ]*\|[\t ]*(\|)/gi, '$1$2');
 myContent.value = myContent.value.replace(/(\{\{Election box[^{}]*[^\t ])[\t ]*\|[\t ]*([\r\n][\t ]*\|)/gi, '$1$2');
 myContent.value = myContent.value.replace(/[\t ]*<section[^<>]*>[\t ]*/gi, '');
 myContent.value = myContent.value.replace(/[\t ]*<!--[^<>]*section[^<>]*transcluded[^<>]*-->[\t ]*/gi, '');
 }
 myContent.value = myContent.value.replace(/(\{\{#section)(:[^{}\|]*constituency[ ]*\|)[ ]*(?:General|Assembly) Election[ ]*([0-9]+)[ ]*(\}\})/gi, '{'+'{trim|$1-h$2$3$4}'+'}');
 myContent.value = myContent.value.replace(/(\{\{#section)(:[^{}\|]*constituency[ ]*\|)[ ]*Assembly (By-election)[ ]*([0-9]+)[ ]*(\}\})/gi, '{'+'{trim|$1-h$2$4 $3$5}'+'}');

 myContent.value = myContent.value.replace(/\|\-[\t ]*bgcolor[ ]*=["' ]*([^{}\|\r\n"']*)["' ]*(\{\{[_ ]*[Vv]b(?:\{\{[^{}]*\}\}|[^{}])*)/g, '$2|bc=$1');
 myContent.value = myContent.value.replace(/(\{\{[_ ]*[Vv]b[_ ]+res[^\r\n]*[\r\n])\|\}/gi, '$1{'+'{end}'+'}');
 myContent.value = myContent.value.replace(/\*[ ]*(\{\{(?:main|details|further|see also))/gi, '$1');
 for(var k=0; k<6; ++k) {
 myContent.value = myContent.value.replace(/((?:win|loss)[345]s)_[0-9]([ ]*=[0-9]+[ ]*\|[ ]*[a-z0-9]+)(_[A-Z]+)/g, '$1$3$2$3');
 }
 myContent.value = myContent.value.replace(/(\|[ ]*text_QQF[ ]*=)[ ]*([\r\n])/g, '$1 [[#Final round|Quarterfinals]]$2');
 myContent.value = myContent.value.replace(/(\|[ ]*text_QSF[ ]*=)[ ]*([\r\n])/g, '$1 [[#Final round|Semifinals]]$2');
 myContent.value = myContent.value.replace(/(\|[ ]*text_E[ ]*=)[ ]*([\r\n])/g, '$1 Eliminated$2');
 myContent.value = myContent.value.replace(/(\|[ ]*text_Q)([EFGHIJKL])([ ]*=)[ ]*([\r\n])/g, '$1$2$3 [[#Pool $2|Pool $2]]$4');
 myContent.value = myContent.value.replace(/((?:win|loss)[345]s_[A-Z]+[ ]*=[ ]*[0-9]+[^\r\n]*)\|[ ]*s[wl]_[A-Z]+[ ]*=[ ]*[0-9][0-9]*/g, '$1');
 myContent.value = myContent.value.replace(/((?:win|loss)[345]s_[A-Z]+[ ]*=[ ]*[0-9]+[^\r\n]*)\|[ ]*s[wl]_[A-Z]+[ ]*=[ ]*[0-9][0-9]*/g, '$1');
 
 myContent.value = myContent.value.replace(/(\{\{)[ ]*#ifeq[ ]*:[ ]*\{\{\{transcludesection[ ]*\|([^{}\|]*)\}\}\}[ ]*\|[ ]*\2[ ]*\|/g, '$1#invoke:transcludable section|main|section=$2|text=');
 myContent.value = myContent.value.replace(/\|[ ]*show_matches[ ]*=[ ]*no([^{}]*\|[ ]*show_matches[ ]*=)/g, '$1');

 myContent.value = myContent.value.replace(/(\{\{[^{}]*LegResult[^\r\n]*[\r\n])\|\}/g, '$1{'+'{end}'+'}');

 myContent.value = myContent.value.replace(/<div[^<>]*right[^<>]*>[\t ]*[\r\n]*[\t ]*(\{\{[_ ]*[Ll]ocation[_ ]*map[^{}]*\|[ ]*float[ ]*=[ ]*)center((?:\{\{(?:\{\{[^{}]*\}\}|[^{}])*\}\}|[^{}])*\}\})[\t ]*[\r\n]*[\t ]*[\r\n]*[\t ]*<\/div>/g, '$1right$2');
 
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*col\-begin[^{}]*\}\}[\t ]*[\r\n]*\{\{[_ ]*col\-[0-9]+[^{}]*(\}\}[ ]*[\r\n](?:'''|;)[^\r\n]*[\r\n]\*[^\r\n]*)/gi, '$1col-float-begin$2<!--' + ' FIX FLOAT ' + '-->');
 myContent.value = myContent.value.replace(/[\r\n]\|\-[\t ]*[^\r\n\t ][^\r\n]*([\r\n]\|\-)/g, '$1');
 myContent.value = myContent.value.replace(/\|[ ]*yearr[ ]*=(?:<!--[^<>]*-->| )*[\r\n]/g, '');
 myContent.value = myContent.value.replace(/[\r\n]\{\|[^\r\n]*right[^\r\n]*[\r\n](?:\|\-[^\r\n]*[\r\n]|)\|[ ]*style[ ]*=[" ]*width[ ]*:3[ ]*px[; "]*\|(?:&nbsp;| )*[\r\n]\|(?:&nbsp;| )*([\r\n])/gi, '$1{'+'{stack begin}'+'}<!-- kill stack -->$1');
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*flagicon[_ ]*\|([^{}]*)(\}\})[ ]*\[\[\2[_ ]*national[_ ]men's[_ ]*inline[_ ]hockey[_ ]team\|\2\]\]/gi, '$1iih|$2$3');
 myContent.value = myContent.value.replace(/\[\[([A-Za-z ]*)[_ ]*national[_ ]men's[_ ]*inline[_ ]hockey[_ ]team\|\1\]\] (\{\{)[_ ]*flagicon[_ ]*\|[ ]*\1[ ]*(\}\})/gi, '$2iih-rt|$1$3');
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*(I)nfobox[_ ]*International[_ ]*Ice[_ ]*Hockey[_ ]*Competition/gi, '$1$2nfobox international ice hockey competition');
 myContent.value = myContent.value.replace(/([\r\n][ ]*\|[ ]*type[ ]*=[ ]*)([a-z0-9]+)([ ]*[\r\n](?:\{\{[^{}]*\}\}|[^{}])*)[\r\n][ ]*\|[ ]*type[ ]*=[ ]*\2/gi, '$1$2$3');
 myContent.value = myContent.value.replace(/([\r\n][ ]*\|[ ]*type[ ]*=[ ]*)([a-z0-9]+)([ ]*[\r\n](?:\{\{[^{}]*\}\}|[^{}])*)[\r\n][ ]*\|[ ]*type[ ]*=[ ]*\2/gi, '$1$2$3');
 myContent.value = myContent.value.replace(/([\r\n][ ]*\|[ ]*type[ ]*=[ ]*)([a-z0-9]+)([ ]*[\r\n](?:\{\{[^{}]*\}\}|[^{}])*)[\r\n][ ]*\|[ ]*type[ ]*=[ ]*\2/gi, '$1$2$3');
 myContent.value = myContent.value.replace(/<!--[ ]*SPLIT TABLE[ ]*-->[ ]*[\r\n]*(\{\|(?:[\r\n]|\{\{[^{}]*\}\}|[^\{\}])*[\r\n]\|\})[ ]*([\r\n])/gm, '<!--'+' SCORE TABLE'+' -->$1$2<!--'+' MATCH TABLE '+'-->$1$2');
 myContent.value = myContent.value.replace(/(<!--[ ]*SCORE[ ]*TABLE[ ]*-->)(\{\|[^\r\n]*)/g, '$2$1');
 myContent.value = myContent.value.replace(/(<!--[ ]*MATCH[ ]*TABLE[ ]*-->)\{\|[^\r\n]*/g, '{'+'{fb r2 header|nt=0}'+'}$1');
 myContent.value = myContent.value.replace(/(![ ]*)Points difference[ ]*([\r\n])/g, '$1 PF$2$1 PA<!--'+' SPLIT POINTS -->$2');
 myContent.value = myContent.value.replace(/(![ ]*)Goal difference[ ]*([\r\n])/g, '$1 GF$2$1 GA<!--'+' SPLIT POINTS -->$2');
 myContent.value = myContent.value.replace(/([\r\n]\|\-[^\r\n]*"[^"]*")[ ]*;[ ]*/g, '$1 ');
 while( lt != myContent.value ) {
 lt = myContent.value;
 myContent.value = myContent.value.replace(/(<!--[ ]*FIX FLOAT[ ]*-->)([\r\n][^\{][^\r\n]*)/g, '$2$1');
 myContent.value = myContent.value.replace(/<!--[ ]*FIX FLOAT[ ]*-->(?:[\r\n]\{\{[_ ]*col\-[0-9]+[^{}]*\}\}|)[ ]*([\r\n]*\{\{)[_ ]*col\-end[^{}]*(\}\})/gi, '$1col-float-end$2');
 myContent.value = myContent.value.replace(/(<!--[ ]*FIX FLOAT[ ]*-->)([\r\n]\{\{)[_ ]*col\-[0-9]+[^{}]*(\}\}[^\r\n]*)/gi, '$2col-float-break$3$1');
 myContent.value = myContent.value.replace(/(<!--[ ]*kill stack[ ]*-->)[ ]*([\r\n][^\|\r\n][^\r\n]*)/gi, '$2$1');
 myContent.value = myContent.value.replace(/(<!--[ ]*kill stack[ ]*-->)[ ]*([\r\n])([\r\n])/gi, '$2$1$3');
 myContent.value = myContent.value.replace(/<!--[ ]*kill stack[ ]*-->[ ]*([\r\n])\|\}/gi, '$1{'+'{stack end}'+'}');
 
 myContent.value = myContent.value.replace(/(<!--[ ]*SCORE[ ]*TABLE[ ]*-->)([\r\n]\|\-[^\r\n]*)/g, '$2$1');
 myContent.value = myContent.value.replace(/(<!--[ ]*MATCH[ ]*TABLE[ ]*-->)[\r\n]\|\-[^\r\n]*/g, '$1');
 myContent.value = myContent.value.replace(/(<!--[ ]*SCORE[ ]*TABLE[ ]*-->)([\r\n]![^\r\n]*Team[^\r\n]*)/g, '$2$1');
 myContent.value = myContent.value.replace(/(<!--[ ]*MATCH[ ]*TABLE[ ]*-->)[\r\n]![^\r\n]*Team[^\r\n]*/g, '$1');
 myContent.value = myContent.value.replace(/(<!--[ ]*SCORE[ ]*TABLE[ ]*-->)([\r\n]!(?:width[^\|\r\n]*\||)[ ]*(?:GP|W|L|T|GF|GA|PTS|Rank)[^\r\n]*)/g, '$2$1');
 myContent.value = myContent.value.replace(/(<!--[ ]*MATCH[ ]*TABLE[ ]*-->)[\r\n]!(?:width[^\|\r\n]*\||)[ ]*(?:GP|W|L|T|GF|GA|PTS|Rank)[^\r\n]*/g, '$1');
 myContent.value = myContent.value.replace(/(<!--[ ]*(?:SCORE|MATCH)[ ]*TABLE[ ]*-->)[\r\n]![ ]*rowspan=[0-9]*[ ]*\|[ ]*/g, '$1');
 myContent.value = myContent.value.replace(/(<!--[ ]*SCORE[ ]*TABLE[ ]*-->)[\r\n]!(?:width[^\|\r\n]*\||)[ ]*\{\{(?:flagicon|ih)[^{}]*\}\}[ ]*[^\r\n]*/g, '$1');
 myContent.value = myContent.value.replace(/(\{\{fb r2 header\|nt)=0(\}\})[ ]*(<!--[ ]*MATCH TABLE[ ]*-->)[ ]*[\r\n]![ ]*\{\{flagicon\|([^{}\|]*)(?:\|[^{}]*|)\}\}/g, '$1=1|$4$2$3');
 for(var k=1; k<10; k++) {
 var re = new RegExp('(\\{\\{fb r2 header\\|nt)=' + k + '([^{}]*)(\\}\\})[ ]*(<!--[ ]*MATCH TABLE[ ]*-->)[ ]*[\r\n]![ ]*\\{\\{flagicon\\|([^{}\\|]*)(?:\\|[^{}]*|)\\}\\}', 'g');
 myContent.value = myContent.value.replace(re, '$1=' + (k+1) + '$2|$5$3$4');
 }
 myContent.value = myContent.value.replace(/(<!--[ ]*SCORE[ ]*TABLE[ ]*-->)([\r\n](?:\|[ ]*[0-9]+\.?[ ]*\||)\|[ ]*style[^\r\n]*\{\{ih[^\r\n]*)/g, '$2$1');
 myContent.value = myContent.value.replace(/(<!--[ ]*MATCH[ ]*TABLE[ ]*-->)([\r\n])(?:\|[ ]*[0-9]+\.?[ ]*\||)\|[ ]*style[^\r\n]*(\{\{ih[^\r\n]*)/g, '$2{'+'{fb r2 team|t=$3}'+'}$1');
 myContent.value = myContent.value.replace(/(<!--[ ]*SCORE[ ]*TABLE[ ]*-->)([\r\n]\|[ ]*[0-9]*[ ]*\|[^\-\r\n']*'''[ ]*[0-9]*[ ]*''')[ ]*\|\|[^\r\n]*/g, '$2$1');
 myContent.value = myContent.value.replace(/(<!--[ ]*MATCH[ ]*TABLE[ ]*-->)([\r\n])\|[ ]*[0-9]*[ ]*\|[^\-\r\n']*'''[ ]*[0-9]*[ ]*'''[ ]*\|(\|[^\r\n]*)/g, '$2$3$1');
 myContent.value = myContent.value.replace(/(<!--[ ]*SPLIT POINTS[ ]*-->)([\r\n](?:!|\|\-)[^\r\n]*)/g, '$2$1');
 myContent.value = myContent.value.replace(/(<!--[ ]*SPLIT POINTS[ ]*-->)((?:[\r\n]\|[^\-\r\n][^\r\n]*|)[\r\n][^\r\n]*\|\|)(?:\{\{0\}\}|[ ])*([0-9]+)(?:\{\{0\}\}|[ ])*[–\-:](?:\{\{0\}\}|[ ])*([0-9])(?:\{\{0\}\}|[ ])*([^\r\n]*)/g, '$2 $3 || $4$5$1');
 myContent.value = myContent.value.replace(/(<!--[ ]*SPLIT POINTS[ ]*-->)([\r\n]\|\-[^\r\n]*)/g, '$2$1');
 myContent.value = myContent.value.replace(/(<!--[ ]*SPLIT POINTS[ ]*-->)([\r\n]\|\}[^\r\n]*)/g, '$2');
 myContent.value = myContent.value.replace(/(\{\{fb r(?:\{\{[^{}]*\}\}|[^{}])*\}\})[ ]*([\r\n])\|[ ]*\|(\|)/g, '$1$2{'+'{fb r|r=null}'+'}$2$3');
 myContent.value = myContent.value.replace(/(\{\{fb r(?:\{\{[^{}]*\}\}|[^{}])*\}\})[ ]*([\r\n])\|[ ]*([0-9]+)[ ]*[–\-][ ]*([0-9]+)[ ]*\|(\|)/g, '$1$2{'+'{fb r|gf=$3|ga=$4}'+'}$2$5');
 myContent.value = myContent.value.replace(/(\{\{fb r(?:\{\{[^{}]*\}\}|[^{}])*\}\})[ ]*([\r\n])\|[ ]*([\r\n])/g, '$1$2{'+'{fb r|r=null}'+'}$2');
 myContent.value = myContent.value.replace(/(\{\{fb r(?:\{\{[^{}]*\}\}|[^{}])*\}\})[ ]*([\r\n])\|[ ]*([0-9]+)[ ]*[–\-][ ]*([0-9]+)[ ]*([\r\n])/g, '$1$2{'+'{fb r|gf=$3|ga=$4}'+'}$2');
 myContent.value = myContent.value.replace(/(<!--[ ]*(?:MATCH|SCORE) TABLE[ ]*-->)([\r\n]\|\}[^\r\n]*)/g, '$2');
 }
 myContent.value = myContent.value.replace(/\{\|[^\r\n]*[\r\n](?:\|\-[^\r\n]*[\r\n]|)![\t ]*[\r\n]![\t ]*Team[\t ]*[\r\n]![\t ]*Games[\t ]*[\r\n]![\t ]*Won[\t ]*[\r\n]![\t ]*Drawn[\t ]*[\r\n]![\t ]*Lost[\t ]*[\r\n]![\t ]*[GP]F[\t ]*[\r\n]![\t ]*[GP]A[\t ]*[\r\n]![\t ]*Points[\t ]*/gm, '{'+'{fb cl header|winpoints=2}'+'}');
 if (mw.config.get('wgNamespaceNumber') == 0) { 
 myContent.value = myContent.value.replace(/(\{\{[_ ]*[Ii]nfobox[^{}]*name[ ]*=[ ]*(?:[^\[\]\{\}\|<>\r\n]|\{\{[^{}]*\}\}|\[\[[^\[\]]*\]\])*)'''/g, '$1');
 myContent.value = myContent.value.replace(/(\{\{[_ ]*[Ii]nfobox[^{}]*name[ ]*=[ ]*(?:[^\[\]\{\}\|<>\r\n]|\{\{[^{}]*\}\}|\[\[[^\[\]]*\]\])*)<small>/g, '$1');
 myContent.value = myContent.value.replace(/(\{\{[_ ]*[Ii]nfobox[^{}]*name[ ]*=[ ]*(?:[^\[\]\{\}\|<>\r\n]|\{\{[^{}]*\}\}|\[\[[^\[\]]*\]\])*)'''/g, '$1');
 myContent.value = myContent.value.replace(/(\{\{[_ ]*[Ii]nfobox[^{}]*name[ ]*=[ ]*(?:[^\[\]\{\}\|<>\r\n]|\{\{[^{}]*\}\}|\[\[[^\[\]]*\]\])*)<\/small>/g, '$1');
 myContent.value = myContent.value.replace(/(\{\{[_ ]*[Ii]nfobox[^{}]*\|[ ]*name[ ]*[ ]*[^\r\n<>{}]*)<[^<>]*br[^<>]*>[ ]*([^A-Za-z \r\n\|])/g, '$1\n| native_name = $2');
 }
 
 myContent.value = myContent.value.replace(/(system[ ]*=[ ]*)(RE|RB)\-NRW([ ]*\|[ ]*line[ ]*=)[ ]*/g, '$1DB Regio NRW$3$2 ');
 myContent.value = myContent.value.replace(/(system[0-9 ]*=[ ]*Arriva) (Stoptrein|Sneltrein)(?:\|[ ]*hide\-system[0-9]*[ ]*=[a-z ]*|[ ])*([\r\n]?[ ]*\|[ ]*line[0-9 ]*=)[ ]*([0-9])/g, '$1 Netherlands$3$2 $4');
 myContent.value = myContent.value.replace(/(line[0-9 ]*=[ ]*)(Stoptrein|Sneltrein)([ ]*[0-9][^\r\n]*[\r\n][ ]*\|[ ]*line[0-9 ]*=)[ ]*([0-9])/g, '$1$2$3$2 $4');

 myContent.value = myContent.value.replace(/(\{\{[0-9]+(?:Round|Team)Bracket)\-Compact\-NoSeeds\-Byes(?:\-with 3rd|\-with third|\-v2|)[\t ]*([\r\n]|\|)/g, '$1|compact=y|seeds=n|byes=1\n|nowrap=y$2');
 myContent.value = myContent.value.replace(/(\{\{[0-9]+(?:Round|Team)Bracket)\-Compact\-NoSeeds(?:\-with 3rd|\-with third|\-v2|)[\t ]*([\r\n]|\|)/g, '$1|compact=y|seeds=n\n|nowrap=y$2');
 myContent.value = myContent.value.replace(/(\{\{[0-9]+(?:Round|Team)Bracket)\-Compact\-(?:Squash|Tennis)([0-9])\-Byes(?:\-with 3rd|\-with third|\-v2|)[\t ]*([\r\n]|\|)/g, '$1|compact=y|sets=$2|byes=1|seeds=y|nowrap=y$3');
 myContent.value = myContent.value.replace(/(\{\{[0-9]+(?:Round|Team)Bracket)\-Compact\-(?:Squash|Tennis)([0-9])(?:\-with 3rd|\-with third|\-v2|)[\t ]*([\r\n]|\|)/g, '$1|compact=y|sets=$2|seeds=y|nowrap=y$3');
 myContent.value = myContent.value.replace(/(\{\{[0-9]+(?:Round|Team)Bracket)\-(?:Squash|Tennis)([0-9])\-Byes(?:\-with 3rd|\-with third|\-v2|)[\t ]*([\r\n]|\|)/g, '$1|sets=$2|byes=1|seeds=y|nowrap=y$3');
 myContent.value = myContent.value.replace(/(\{\{[0-9]+(?:Round|Team)Bracket)\-(?:Squash|Tennis)([0-9])(?:\-with 3rd|\-with third|\-v2|)[\t ]*([\r\n]|\|)/g, '$1|sets=$2|seeds=y|nowrap=y$3');
 myContent.value = myContent.value.replace(/(\{\{[0-9]+(?:Round|Team)Bracket)\-Compact(?:\-with 3rd|\-with third|\-v2|)[\t ]*([\r\n]|\|)/g, '$1|compact=y\n|nowrap=y$2');
 myContent.value = myContent.value.replace(/(\{\{[0-9]+(?:Round|Team)Bracket)\-NoSeeds(?:\-with 3rd|\-with third|\-v2|)[\t ]*([\r\n]|\|)/g, '$1|seeds=n\n|nowrap=y$2');
 myContent.value = myContent.value.replace(/(\{\{[0-9]+(?:Round|Team)Bracket)\-Byes(?:\-with 3rd|\-with third|\-v2|)[\t ]*([\r\n]|\|)/g, '$1|byes=1\n|nowrap=y$2');
 myContent.value = myContent.value.replace(/\|[ ]*nowrap[ ]*=[ ]*y[ ]*[\r\n]*([^{}]*\|[ ]*nowrap[ ]*=)/g, '$1');
 myContent.value = myContent.value.replace(/\|[ ]*seeds[ ]*=[ ]*y[ ]*[\r\n]*([^{}]*\|[ ]*seeds[ ]*=)/g, '$1');
 
 myContent.value = myContent.value.replace(/(\{\{[Ss]\-line[^{}]*\|system=[ ]*)(Alvia|AVE|Avant|Media Distancia)(\|[ ]*line[ ]*=[ ]*)(\|)/g, '$1Renfe$3$2$4');
 myContent.value = myContent.value.replace(/branch[ ]*=[ ]*<big>([0-9]*)<\/big>/g, 'note-mid=$1');
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*Historical[_ ]*Rail[_ ]*Insert[_ ]*(\}\})/gi, '$1s-note|text=Historical railways$2');
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*Disused[_ ]*Rail[_ ]*Insert[_ ]*(\}\})/gi, '$1s-note|text=Disused railways$2');
 // myContent.value = myContent.value.replace(/\{\|[^\r\n]*[\r\n](?:\|\-[^\r\n]*[\r\n]|)\|\}[\t ]*[\r\n]/g, '');
 
 while( lt != myContent.value ) {
 lt = myContent.value;
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*([Rr]ail[_ ]*line(?:\{\{[^{}]*}}|[^{}])*)[\r\n]/g, '$1$2 ');
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*([Rr]ail[_ ]*line(?:\{\{[^{}]*}}|[^{}])*)[\t ][\t ]+/g, '$1$2 ');
 }
 lt = '';
 if(0) {
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*[Rr]ail[_ ]*line[_ ]*(?:two[_ ]*to[_ ]*one|one[_ ]*to[_ ]*two)/g, '$1rail line<!-- '+' SPLIT1-->}'+'}\n$1rail line<!--'+' SPLIT2-->');
 myContent.value = myContent.value.replace(/(<!--[ ]*SPLIT1[ ]*-->)([^\r\n]*[\r\n][^\r\n]*<!--[ ]*SPLIT2[ ]*-->(?:\{\{[^{}]*\}\}|[^{}\r\n])*)(\|[ ]*previous)1([ ]*=(?:\{\{[^{}]*\}\}|\[\[[^\[\]]*\]\]|[^{}\[\]\|])*)([\|\}])/g, '$1$3$4$2$5');
 myContent.value = myContent.value.replace(/(<!--[ ]*SPLIT1[ ]*-->)([^\r\n]*[\r\n][^\r\n]*<!--[ ]*SPLIT2[ ]*-->(?:\{\{[^{}]*\}\}|[^{}\r\n])*)(\|[ ]*next)1([ ]*=(?:\{\{[^{}]*\}\}|\[\[[^\[\]]*\]\]|[^{}\[\]\|])*)([\|\}])/g, '$1$3$4$2$5');
 myContent.value = myContent.value.replace(/(<!--[ ]*SPLIT1[ ]*-->)([^\r\n]*[\r\n][^\r\n]*<!--[ ]*SPLIT2[ ]*-->(?:\{\{[^{}]*\}\}|[^{}\r\n])*)(\|[ ]*route)1([ ]*=(?:\{\{[^{}]*\}\}|\[\[[^\[\]]*\]\]|[^{}\[\]\|])*)([\|\}])/g, '$1$3$4$2$5');
 myContent.value = myContent.value.replace(/(<!--[ ]*SPLIT1[ ]*-->)([^\r\n]*[\r\n][^\r\n]*<!--[ ]*SPLIT2[ ]*-->(?:\{\{[^{}]*\}\}|[^{}\r\n])*)(\|[ ]*col)1([ ]*=(?:\{\{[^{}]*\}\}|\[\[[^\[\]]*\]\]|[^{}\[\]\|])*)([\|\}])/g, '$1$3$4$2$5');
 myContent.value = myContent.value.replace(/(<!--[ ]*SPLIT1[ ]*-->)([^\r\n]*[\r\n][^\r\n]*<!--[ ]*SPLIT2[ ]*-->(?:\{\{[^{}]*\}\}|[^{}\r\n])*)(\|[ ]*previous)([ ]*=(?:\{\{[^{}]*\}\}|\[\[[^\[\]]*\]\]|[^{}\[\]\|])*)([\|\}])/g, '$1$3$4$2$3$4$5');
 myContent.value = myContent.value.replace(/(<!--[ ]*SPLIT1[ ]*-->)([^\r\n]*[\r\n][^\r\n]*<!--[ ]*SPLIT2[ ]*-->(?:\{\{[^{}]*\}\}|[^{}\r\n])*)(\|[ ]*next)([ ]*=(?:\{\{[^{}]*\}\}|\[\[[^\[\]]*\]\]|[^{}\[\]\|])*)([\|\}])/g, '$1$3$4$2$3$4$5');
 myContent.value = myContent.value.replace(/(<!--[ ]*SPLIT1[ ]*-->)([^\r\n]*[\r\n][^\r\n]*<!--[ ]*SPLIT2[ ]*-->(?:\{\{[^{}]*\}\}|[^{}\r\n])*)(\|[ ]*route)([ ]*=(?:\{\{[^{}]*\}\}|\[\[[^\[\]]*\]\]|[^{}\[\]\|])*)([\|\}])/g, '$1$3$4$2$3$4$5');
 myContent.value = myContent.value.replace(/(<!--[ ]*SPLIT1[ ]*-->)([^\r\n]*[\r\n][^\r\n]*<!--[ ]*SPLIT2[ ]*-->(?:\{\{[^{}]*\}\}|[^{}\r\n])*)(\|[ ]*col)([ ]*=(?:\{\{[^{}]*\}\}|\[\[[^\[\]]*\]\]|[^{}\[\]\|])*)([\|\}])/g, '$1$3$4$2$3$4$5');
 myContent.value = myContent.value.replace(/(<!--[ ]*SPLIT2[ ]*-->(?:\{\{[^{}]*\}\}|[^{}\r\n])*\|[ ]*previous)2([ ]*=(?:\{\{[^{}]*\}\}|\[\[[^\[\]]*\]\]|[^{}\[\]\|])*[\|\}])/g, '$1$2');
 myContent.value = myContent.value.replace(/(<!--[ ]*SPLIT2[ ]*-->(?:\{\{[^{}]*\}\}|[^{}\r\n])*\|[ ]*next)2([ ]*=(?:\{\{[^{}]*\}\}|\[\[[^\[\]]*\]\]|[^{}\[\]\|])*[\|\}])/g, '$1$2');
 myContent.value = myContent.value.replace(/(<!--[ ]*SPLIT2[ ]*-->(?:\{\{[^{}]*\}\}|[^{}\r\n])*\|[ ]*route)2([ ]*=(?:\{\{[^{}]*\}\}|\[\[[^\[\]]*\]\]|[^{}\[\]\|])*[\|\}])/g, '$1$2');
 myContent.value = myContent.value.replace(/(<!--[ ]*SPLIT2[ ]*-->(?:\{\{[^{}]*\}\}|[^{}\r\n])*\|[ ]*col)2([ ]*=(?:\{\{[^{}]*\}\}|\[\[[^\[\]]*\]\]|[^{}\[\]\|])*[\|\}])/g, '$1$2');
 myContent.value = myContent.value.replace(/<!--[ ]*SPLIT[12]-->/g, '');
 }
 
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*[Rr]ail[_ ]*line[_ ]*(\|(?:\{\{[^{}]*\}\}|[^{}\r\n])*|)\|[ ]*route[ ]*=[ ]*\[\[Intercity[^{}]*Renfe[^{}]*\]\][ ]*\|[ ]*col[ ]*=[ ]*\{\{(Larga Distancia) color\}\}[ ]*/g, '$1S-line|system=Renfe|line=$3$2');
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*[Rr]ail[_ ]*line[_ ]*(\|(?:\{\{[^{}]*\}\}|[^{}\r\n])*|)\|[ ]*col[ ]*=[ ]*\{\{(Larga Distancia) color\}\}[ ]*\|[ ]*route[ ]*=[ ]*\[\[Intercity[^{}]*Renfe[^{}]*\]\][ ]*/g, '$1S-line|system=Renfe|line=$3$2');
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*[Rr]ail[_ ]*line[_ ]*(\|(?:\{\{[^{}]*\}\}|[^{}\r\n])*|)\|[ ]*route[ ]*=[ ]*\[\[Intercity[^{}]*Renfe[^{}]*\]\][ ]*\|[ ]*col[ ]*=[ ]*\{\{Media Distancia color\}\}[ ]*/g, '$1S-line|system=Renfe|line=Intercity$2');
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*[Rr]ail[_ ]*line[_ ]*(\|(?:\{\{[^{}]*\}\}|[^{}\r\n])*|)\|[ ]*col[ ]*=[ ]*\{\{Media Distancia color\}\}[ ]*\|[ ]*route[ ]*=[ ]*\[\[Intercity[^{}]*Renfe[^{}]*\]\][ ]*/g, '$1S-line|system=Renfe|line=Intercity$2');
 myContent.value = myContent.value.replace(/(\{\{[_ ]*[Ss]\-line(?:\{\{[^{}]*\}\}|[^{}\r\n])*\|[ ]*previous[ ]*=[ ]*)\{\{Stnlnk\|([^{}]*)\}\}/g, '$1$2');
 myContent.value = myContent.value.replace(/(\{\{[_ ]*[Ss]\-line(?:\{\{[^{}]*\}\}|[^{}\r\n])*\|[ ]*next[ ]*=[ ]*)\{\{Stnlnk\|([^{}]*)\}\}/g, '$1$2');
 
 myContent.value = myContent.value.replace(/(\{\{[_ ]*[Ss]\-line(?:\{\{[^{}]*\}\}|[^{}\r\n])*\|[ ]*previous[ ]*=[ ]*)((?:\{\{[^{}]*\}\}|\[\[[^\[\]]*\]\]|[^{}\[\]\|])*)<br[^<>]*><small>[' ]*terminus[ ']*/gi, '$1$2|type=$2');
 myContent.value = myContent.value.replace(/(\{\{[_ ]*[Ss]\-line(?:\{\{[^{}]*\}\}|[^{}\r\n])*\|[ ]*next[ ]*=[ ]*)((?:\{\{[^{}]*\}\}|\[\[[^\[\]]*\]\]|[^{}\[\]\|])*)<br[^<>]*><small>[' ]*terminus[ ]*/gi, '$1$2|type2=$2');
 myContent.value = myContent.value.replace(/(\{\{[_ ]*[Ss]\-line(?:\{\{[^{}]*\}\}|[^{}\r\n])*\|[ ]*previous[ ]*=[ ]*(?:\{\{[^{}]*\}\}|\[\[[^\[\]]*\]\]|[^{}\[\]\|])*)<br[^<>]*><small>[' ]*towards?[ ]*/gi, '$1|type=');
 myContent.value = myContent.value.replace(/(\{\{[_ ]*[Ss]\-line(?:\{\{[^{}]*\}\}|[^{}\r\n])*\|[ ]*next[ ]*=[ ]*(?:\{\{[^{}]*\}\}|\[\[[^\[\]]*\]\]|[^{}\[\]\|])*)<br[^<>]*><small>[' ]*towards?[ ]*/gi, '$1|type2=');
 myContent.value = myContent.value.replace(/(\{\{[_ ]*[Ss]\-line(?:\{\{[^{}]*\}\}|[^{}\r\n])*\|[ ]*type[ ]*=[ ]*)\{\{Stnlnk\|([^{}]*)\}\}/g, '$1$2');
 myContent.value = myContent.value.replace(/(\{\{[_ ]*[Ss]\-line(?:\{\{[^{}]*\}\}|[^{}\r\n])*\|[ ]*type2[ ]*=[ ]*)\{\{Stnlnk\|([^{}]*)\}\}/g, '$1$2');
 myContent.value = myContent.value.replace(/(\{\{[_ ]*[Ss]\-line(?:\{\{[^{}]*\}\}|[^{}\r\n])*)[' ]*<\/small>[' ]*/gi, '$1');
 myContent.value = myContent.value.replace(/(\{\{[_ ]*[Ss]\-line(?:\{\{[^{}]*\}\}|[^{}\r\n])*)[' ]*<\/small>[' ]*/gi, '$1');
 myContent.value = myContent.value.replace(/(\{\{[_ ]*[Ss]\-line(?:\{\{[^{}]*\}\}|[^{}\r\n])*)'''/gi, '$1');
 myContent.value = myContent.value.replace(/(\{\{[_ ]*[Ss]\-line(?:\{\{[^{}]*\}\}|[^{}\r\n])*)'''/gi, '$1');
 myContent.value = myContent.value.replace(/(\{\{[_ ]*[Ss]\-line(?:\{\{[^{}]*\}\}|[^{}\r\n])*)''/gi, '$1');
 myContent.value = myContent.value.replace(/(\{\{[_ ]*[Ss]\-line(?:\{\{[^{}]*\}\}|[^{}\r\n])*)''/gi, '$1');


 myContent.value = myContent.value.replace(/(bottom[\t ]*=[\t ]*)<div[^<>]*width:10em;text-align:center[^<>]*>([^<>]*)<\/div>/g, '$1{'+'{center|$2}'+'}');
 myContent.value = myContent.value.replace(/(\{\{[Pp]ortal)[ ]*bar([^{}]*Trains)\|Transport\|Engineering/g, '$1$2');
 myContent.value = myContent.value.replace(/\{\{[Cc]lear\}\}[\t ]*[\r\n]*(\{\{[Pp]ortal)/g, '$1');
 if(myContent.value.search(/(name[ ]*=[ ]*)(\[\[(?:File|Image):Indian_Railways_Suburban_Railway_Logo\.svg\|[0-9]*px\]\])[ ]*<br[^<>]*>/g) >= 0) {
 myContent.value = myContent.value.replace(/(\|[ ]*name[ ]*=[ ]*)(\[\[(?:File|Image):Indian_Railways_Suburban_Railway_Logo\.svg\|[0-9]*px\]\])[ ]*<br[^<>]*>/g, '$1');
 myContent.value = myContent.value.replace(/(\|[ ]*type[ ]*=)[ ]*/, '$1 [[File:Indian_Railways_Suburban_Railway_Logo.svg|30px]] ');
 }
 
 myContent.value = myContent.value.replace(/(\|[ ]*map_dot_label[ ]*=)[ ]*'''[ ]*/g, '$1 ');
 myContent.value = myContent.value.replace(/(\|[ ]*map_dot_label[ ]*=[^{}\|\[\]\r\n]*)[ ]*'''[ ]*/g, '$1 ');
 myContent.value = myContent.value.replace(/note(2?[ ]*=[ ]*)[' ]*(?:\{\{small\|towards\}\}|towards)[' ]*\{\{stnlnk\|([^{}\|]*)\}\}[' ]*/g, 'type$1$2');
 myContent.value = myContent.value.replace(/(\{\{)LOG colou?r(\}\})/g, '$1rcr|London Overground$2');
 myContent.value = myContent.value.replace(/(\{\{[_ ]*[Ss]\-line(?:\{\{[^{}]*\}\}|[^{}])*(?:Indian Railways|Kolkata Suburban Railway)(?:\{\{[^{}]*\}\}|[^{}])*\|[ ]*)branch([ ]*=)/g, '$1note-mid$2');
 myContent.value = myContent.value.replace(/\|[ ]*\{\{subst:DAT[AE]\}\}([^{}]*\|date=)/g, '$1');
 myContent.value = myContent.value.replace(/\{\{subst:lc:([^{}\|=]*)\}\}/g, '$1');
 myContent.value = myContent.value.replace(/(\{\{)[Nn]egara(\|)/g, '$1flagicon$2');
 myContent.value = myContent.value.replace(/<div[ ]*style[ ]*=[" ']*float[ ]*:[ ]*right[; ]*clear[: ]*none[^<>]*>([^<>]*)<\/div>/g, '{'+'{stack|$1}'+'}');
 myContent.value = myContent.value.replace(/(\{\{resize\|88%\|(?:[^{}]|\{\{[^{}]*\}\})*)\}\}([ ]*)\{\{resize\|88%\|/g, '$1$2');
 myContent.value = myContent.value.replace(/(\{\{resize\|88%\|(?:[^{}]|\{\{[^{}]*\}\})*)\}\}([ ]*)\{\{resize\|88%\|/g, '$1$2');
 myContent.value = myContent.value.replace(/(\{\{resize\|88%\|(?:[^{}]|\{\{[^{}]*\}\})*)(\}\})([ ]*\{\{ric\|(?:Karlsruhe Stadtbahn|Rhine-Neckar S-Bahn|S-Bahn Mitteldeutschland)[^{}]*\}\})/g, '$1$3$2');
 
 myContent.value = myContent.value.replace(/(\{\{)[_]*([Ii]nfobox)[_ ]+Station/gi, '$1$2 station');
 myContent.value = myContent.value.replace(/ÖPNV Frankfurt\|(RMV|rmv|Rail|Bus|S|S|s\-bahn)(\}\})/g, 'rint|frankfurt|$1$2');
 myContent.value = myContent.value.replace(/ÖPNV Frankfurt\|(S[0-9]+\|)([0-9]+)px(\}\})/g, 'ric|Rhine-Main S-Bahn|$1size=x$2$3');
 myContent.value = myContent.value.replace(/ÖPNV Frankfurt\|(S[0-9]+\|)([0-9]+\}\})/g, 'ric|Rhine-Main S-Bahn|$1size=x$2');
 myContent.value = myContent.value.replace(/ÖPNV Frankfurt\|(S[0-9]+)/g, 'ric|Rhine-Main S-Bahn|$1');
 myContent.value = myContent.value.replace(/ÖPNV Frankfurt\|(U[0-9]+\|)([0-9]+)px(\}\})/g, 'ric|Frankfurt U-Bahn|$1size=x$2$3');
 myContent.value = myContent.value.replace(/ÖPNV Frankfurt\|(U[0-9]+\|)([0-9]+\}\})/g, 'ric|Frankfurt U-Bahn|$1size=x$2');
 myContent.value = myContent.value.replace(/ÖPNV Frankfurt\|(U[0-9]+)/g, 'ric|Frankfurt U-Bahn|$1');
 myContent.value = myContent.value.replace(/ÖPNV Hamburg\|(U[0-9]+)/g, 'ric|Hamburg U-Bahn|$1');
 myContent.value = myContent.value.replace(/ÖPNV Hamburg\|(S[0-9]+)/g, 'ric|Hamburg S-Bahn|$1');
 myContent.value = myContent.value.replace(/ÖPNV Hamburg\|(A[0-9]+)/g, 'ric|AKN Eisenbahn|$1');
 myContent.value = myContent.value.replace(/ÖPNV Hamburg\|((?:[AUSR]|DB|bus)(?:\|[0-9]+|)\}\})/gi, 'rint|Hamburg|$1');
 myContent.value = myContent.value.replace(/(\{\{ric\|(?:Hamburg [US]\-Bahn|AKN Eisenbahn)\|[^{}\|=]*\|)([0-9]+\}\})/g, '$1size=x$2');
 myContent.value = myContent.value.replace(/(\{\{rint\|[Hh]amburg\|[^{}\|=]*\|)([0-9]+\}\})/g, '$1size=$2');
 myContent.value = myContent.value.replace(/(\{\{ric[^{}]*size=x)(?:11|10|9|8)([ ]*\}\})/g, '$112$2');
 myContent.value = myContent.value.replace(/(\{\{)S-Bahn[\- ]Stuttgart(\|[^{}\|=]*\}\})/g, '$1ric|Stuttgart S-Bahn$2');
 myContent.value = myContent.value.replace(/(name[ ]*=[ ]*)\{\{ric\|Stuttgart S-Bahn\|[Ss]\}\}[ ]*/g, '$1');
 myContent.value = myContent.value.replace(/\{\{rint\|my\|([^{}\|]*)\}\}[ ]*(\{\{)lnl(\|KLRT\|)\1(\}\})/gi, '$2ric$3$1|name=y$4');
 myContent.value = myContent.value.replace(/\{\{rint\|US\|amtrak\}\}[ ]*(\{\{)lnl(\|Amtrak\|)([^{}\|=]*)(\}\})/gi, '$1ric$2$3|name=y$4');
 myContent.value = myContent.value.replace(/\{\{rint\|santaclara\|([^{}\|]*)\}\}[ ]*(\{\{)lnl(\|SCVTA\|)\1(\}\})/gi, '$2ric$3$1|name=y$4');
 myContent.value = myContent.value.replace(/\{\{rint\|taipei\|([^{}\|]*)\}\}[ ]*(\{\{)lnl(\|Taipei Metro\|)\1(\}\})/g, '$2ric$3$1|name=y$4');
 myContent.value = myContent.value.replace(/\{\{rint\|kyiv\|([^{}\|]*)\}\}[ ]*(\{\{)lnl(\|Kyiv Metro\|)\1(\}\})/g, '$2ric$3$1|name=y$4');
 myContent.value = myContent.value.replace(/<span style="background[^<>]*(\{\{)rcr(\|[^{}]*)(\}\})[^<>]*>\[\[[^\[\]]*\|<span[^<>]*>[' ]*Line[^<>\[\]]*<\/span>\]\]<\/span>/gi, '$1rcb$2|route$3');

 if (mw.config.get('wgNamespaceNumber') != 2) {
 if(myContent.value.search(/below[ ]*=[ ]*\[\[[^\[\]]*shipwrecks/g) >= 0) {
 myContent.value = myContent.value.replace(/[\t ]*[\r\n]*[\t ]*[\r\n]*[\t ]*[\r\n]*\|[\t ]*below[\t ]*=(?:\[\[[^\[\]]*shipwrecks[^\[\]]*\]\]|[\t ])*[\t ]*[\r\n]*[\t ]*[\r\n]*(\}\})/g, '\n\n| below= {' + '{Shipwrecks navbox footer|{' + '{subst:#invoke:string|replace|{' + '{subst:PAGENAME}' + '}| shipwrecks}' + '}' + '}' + '}\n}' + '}');
 var editsummary = document.getElementsByName('wpSummary')[0];
 editsummary.value = 'use nav template';
 }
 if(myContent.value.search(/\{\{[Ss]hipwrecks navbox footer/g) >= 0) {
 if(myContent.value.search(/\|[ ]*nowrapitems[ ]*=[ ]*yes/) < 0) {
 myContent.value = myContent.value.replace(/([\r\n][\t ]*\|[ ]*)(listclass[ ]*=[ ]*hlist)[ ]*([\r\n])/g, '$1$2$1nowrapitems = yes$3');
 }
 if(myContent.value.search(/\|[ ]*nowrapitems[ ]*=[ ]*yes/) >= 0) {
 if(myContent.value.search(/&nbsp;/gi) >= 0) {
 myContent.value = myContent.value.replace(/&nbsp;/gi, ' ');
 var editsummary = document.getElementsByName('wpSummary')[0];
 editsummary.value = editsummary.value + ' use nowrapitems instead of multiple &amp;nbsp;';
 }
 }
 }
 }

 myContent.value = myContent.value.replace(/(\}\})[\t ]*[\r\n](\{\{Routemap)[\t ]*([\r\n])[\t ]*\|[\t ]*title[\t ]*=[\t ]*Track layout[\t ]*[\r\n]\|[ ]*title\-bg[ ]*=[ ]*#\{\{[^{}]*\}\}[\t ]*[\r\n]\|[\t ]*title\-color[\t ]*=[\t a-z0-9#]*[\t ]*([\r\n][^{}]*\}\})/g, '| map_name = Track layout$3| route_map = $2|inline=1$4$1');
 myContent.value = myContent.value.replace(/(\{\{coord[^{}]*\}\}[\t ]*[\r\n]*)\|[ ]*(?:lat|lon)_dir[ ]*=[ ]*[NW][\t ]*[\r\n]*/g, '$1');
 myContent.value = myContent.value.replace(/(\{\{coord[^{}]*\}\}[\t ]*[\r\n]*)\|[ ]*(?:lat|lon)_dir[ ]*=[ ]*[NW][\t ]*[\r\n]*/g, '$1');
 myContent.value = myContent.value.replace(/(\{\{[Rr]outemap[\t\r\n ]*)(\|(?:[^{}]|\{\{[^{}]*\}\})*)(\|[ ]*inline[ ]*=[ ]*[A-Za-z]+[\t ]*[\r\n])/g, '$1$3$2');
 myContent.value = myContent.value.replace(/(\{\{[Rr]outemap[\t\r\n ]*\|[ ]*inline[ ]*=[ ]*y[^{}]*)\|[ ]*title\-bg[ ]*=[ ]*(?:\{\{[^{}]*\}\}|[^{}\|])*[\r\n]*/g, '$1');
 myContent.value = myContent.value.replace(/(\{\{[Rr]outemap[\t\r\n ]*\|[ ]*inline[ ]*=[ ]*y[^{}]*)\|[ ]*title\-color[ ]*=[a-z ]*[\r\n]*/g, '$1');
 myContent.value = myContent.value.replace(/(\{\{[Rr]outemap[\t\r\n ]*\|[ ]*inline[ ]*=[ ]*y[^{}]*)\|[ ]*style[^\r\n\|{}]*[\r\n]*/g, '$1');
 myContent.value = myContent.value.replace(/(\{\{)NYCS stations[^{}]*\{\{S-line\/NYCS left\/Flushing\}\}(\}\})/gi, '$1stl|NYCS|34th Street–Hudson Yards$2');
 myContent.value = myContent.value.replace(/(\{\{)NYCS stations[^{}]*\{\{S-line\/NYCS right\/Flushing\}\}(\}\})/gi, '$1stl|NYCS|Flushing–Main Street$2');
 
 myContent.value = myContent.value.replace(/^([\t ]*\|[\t ]*)([A-Za-z0-9]+[ ]?=[^\r\n]*[\r\n]\|)[ ]*([A-Za-z0-9]+) [ ]*(=[^\r\n]*[\r\n])\1([A-Za-z0-9]+[ ]?=)/g, '$1$2$3$4$1$5');
 
 myContent.value = myContent.value.replace(/(\|line)([0-9]*)(=[A-E])(\|(?:left|right)\2[ ]*=[^\r\n]*)\|to\-left\2=([A-Ea-e][0-9][^\r\n\|\{\}]*)\|to\-right\2=([A-Ea-e][0-9][^\r\n\|\{\}]*)/g, '$1$2$3|type$2=$5–$6$4');
 myContent.value = myContent.value.replace(/(\|line)([0-9]*)(=[A-E])(\|(?:left|right)\2[ ]*=[^\r\n]*)\|to\-left\2=([A-Ea-e][0-9][^\r\n\|\{\}]*)/g, '$1$2$3|type$2=$5$4');
 myContent.value = myContent.value.replace(/(\|line)([0-9]*)(=[A-E])(\|(?:left|right)\2[ ]*=[^\r\n]*)\|to\-right\2=([A-Ea-e][0-9][^\r\n\|\{\}]*)/g, '$1$2$3|type$2=$5$4');

 myContent.value = myContent.value.replace(/(\{\{stl\|[^{}\|]*\|)[ ]*station[ ]*=[ ]*/g, '$1');
 myContent.value = myContent.value.replace(/(\{\{(?:stl|rcr)[^{}]*) (\}\})/g, '$1$2');
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*GOs[_ ]*(\|)/gi, '$1stl|GO Transit|');
 myContent.value = myContent.value.replace(/(type[\t ]*=['\t ]*)(?:<span[^<>]*>|)[\t ]*(\[\[[^\[\]]*)<span[^<>]*color:black[^<>]*>([^<>]*)<\/span>/g, '$1$2{{black|$3}}');
 
 myContent.value = myContent.value.replace(/(\{\{)(KIEVMETRO-line)/g, '$1subst:$2');
 myContent.value = myContent.value.replace(/(\{\{Kyiv Metro)[_ ]Lines/g, '$1');
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*(?:KRTS|KMRT)[_ ]+color/g, '$1rcr|KMRT');
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*[Cc]olor[_ ]*box[^{}]*\{\{rcr(\|[^{}]*)(\}\})[^{}]*\}\}[ ]*\[\[([^\[\]\|]*) line\]\]/g, '$1rcb$2|$4|inline=yes$3');
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*[Cc]olor[_ ]*box[^{}]*\{\{rcr(\|[^{}]*)(\}\})[^{}]*\}\}[ ]*\[\[([^\[\]\|]*) line(?: \(Taiwan\)|)\|[^\[\]\|]*\]\]/g, '$1rcb$2|$4|inline=yes$3');
 
 myContent.value = myContent.value.replace(/<span style="color:[# ]*(\{\{)(?:rcr|rail color)[ ]*(\|[^{}]*)(\}\})[;" ]*>●<\/span>[\t ]*\[\[[^\[\]]*\]\]/g, '$1rcb$2|dot$3');
 myContent.value = myContent.value.replace(/\[\[Mugunghwa-ho\|<span[^<>]*(\{\{)rcr(\|Korail\|[^{}\|]*)(\}\})[^<>]*>[^<>]*Mugunghwa-ho[^<>]*<\/span>\]\]/g, '$1rcb$2|route$3');
 myContent.value = myContent.value.replace(/\[\[Donghae Line\|<span[^<>]*(\{\{)rcr(\|Busan Metro\|[^{}\|]*)(\}\})[^<>]*>[^<>]*Donghae[^<>]*<\/span>\]\]/g, '$1rcb$2|route$3');
 myContent.value = myContent.value.replace(/\[\[Busan Metro Line [1-4]\|<span[^<>]*(\{\{)rcr(\|Busan Metro\|[^{}\|]*)(\}\})[^<>]*>[^<>]*[1-4][^<>]*<\/span>\]\]/g, '$1rcb$2|route$3');
 myContent.value = myContent.value.replace(/\[\[Busan[\-–]Gimhae Light Rail Transit\|<span[^<>]*(\{\{)rcr(\|Busan Metro\|[^{}\|]*)(\}\})[^<>]*>[^<>]*Busan[\-–]Gimhae[^<>]*<\/span>\]\]/g, '$1rcb$2|route$3');
 
 myContent.value = myContent.value.replace(/bgcolor[ ]*=['" ]*(\{\{rcr[^{}]*\}\})[" ]*\|[ ]*<center><span style="color:white[;" ]*>([^<>]*)<\/span><\/center>/g, 'style="background:#$1;color:white;text-align:center;" | $2');

 if (mw.config.get('wgNamespaceNumber') == 0) { 
 myContent.value = myContent.value.replace(/([^\/]gallery)[_ ]*perrow[ ]*=[ ]*[0-9]+[ ]*(>)/gi, '$1$2');
 myContent.value = myContent.value.replace(/([^\/]gallery)[_ ]*(>)/gi, '$1 widths=180$2');
 }
 myContent.value = myContent.value.replace(/(\[\[Line [^\|\[\]*]), (Suzhou Rail Transit)(\|)/g, '$1 ($2)$3');
 myContent.value = myContent.value.replace(/([^\r\n\|])(\{\{s(?:\-rail|)\-start)/gi, '$1\n$2');
 myContent.value = myContent.value.replace(/(\{\{s(?:\-rail|)\-end[^{}]*\}\})[\t ]*(\{\{)/gi, '$1\n$2');
 myContent.value = myContent.value.replace(/(\{\{s\-line[^{}]*)\|[ ]*previous[ ]*=[^{}\|]*((?:\|[^{}]*|)\|[ ]*hide1[ ]*=[ ]*[a-z]+)/gi, '$1$2');
 myContent.value = myContent.value.replace(/(\{\{s\-line[^{}]*)\|[ ]*next[ ]*=[^{}\|]*((?:\|[^{}]*|)\|[ ]*hide2[ ]*=[ ]*[a-z]+)/gi, '$1$2');
 myContent.value = myContent.value.replace(/(\{\{s\-line[^{}]*\|[ ]*hide1[ ]*=[ ]*[a-z][^{}]*)\|[ ]*previous[ ]*=[^{}\|]*/gi, '$1');
 myContent.value = myContent.value.replace(/(\{\{s\-line[^{}]*\|[ ]*hide2[ ]*=[ ]*[a-z][^{}]*)\|[ ]*next[ ]*=[^{}\|]*/gi, '$1');
 
 myContent.value = myContent.value.replace(/system[ ]*=[ ]*LUL/g, 'system=London Underground');
 myContent.value = myContent.value.replace(/system[ ]*=[ ]*MSR/g, 'system=Milan S Lines');
 myContent.value = myContent.value.replace(/system[ ]*=[ ]*RMSB/g, 'system=Rhine-Main S-Bahn');
 myContent.value = myContent.value.replace(/system[ ]*=[ ]*RER/g, 'system=Réseau Express Régional');
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*RMSB[_ ]+(color|lines|stations)/g, '$1Rhine-Main S-Bahn $2');
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*RER[_ ]+(color|lines|stations)/g, '$1Réseau Express Régional $2');
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*LUL[_ ]+colour/g, '$1LUL color');
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*LUL[_ ]+(color|lines)/g, '$1London Underground $2');
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*luls/gi, '$1stl|LUL');

 myContent.value = myContent.value.replace(/([^\r\n\|][\r\n])[\t\r\n ]*(\{\{s(?:\-rail|)\-start[^{}]*\}\}[\t ]*[\r\n]*\{\{s\-rail[^{}]*(?:Indian Railways|Kolkata Suburban Railway|BE|NMBS\/SNCB|NMBS)[ ]*\}\}[\t ]*[\r\n]*(?:\{\{s\-(?:note|line)(?:\{\{[^{}]*\}\}|[^{}])*\}\}|[\t ]|[\r\n])*\{\{[^{}]*end\}\})/gi, '$1{'+'{subst:#invoke:string|replace|{'+'{subst:#invoke:adjacent stations| convert |$2}'+'}|note-mid|type}'+'}');
 myContent.value = myContent.value.replace(/(=)[\t\r\n ]*(\{\{s\-rail[^{}]*(?:Indian Railways|Kolkata Suburban Railway|BE|NMBS\/SNCB|NMBS)[ ]*\}\}[\t ]*[\r\n]*(?:\{\{s\-(?:rail|line|note)[^{}]*\}\}|[\t ]|[\r\n])*\{\{s\-(?:note|line)(?:\{\{[^{}]*\}\}|[^{}])*\}\})/gi, '$1 {'+'{subst:#invoke:string|replace|{'+'{subst:#invoke:adjacent stations|convert|$2}'+'}|note-mid|type}'+'}');
 myContent.value = myContent.value.replace(/([^\r\n\|][\r\n])[\t\r\n ]*(\{\{s(?:\-rail|)\-start[^{}]*\}\}[\t ]*[\r\n]*\{\{s\-rail[^{}]*(?:SNCF|Transilien|RER|Réseau Express Régional|Rhine-Main S-Bahn|RMSB|Milan S Lines|MSR|Pakistan Railways|Nederlandse Spoorwegen)[ ]*\}\}[\t ]*[\r\n]*(?:\{\{s\-(?:note|line)[^{}]*\}\}|[\t ]|[\r\n])*\{\{[^{}]*end\}\})/gi, '$1{'+'{subst:#invoke:adjacent stations| convert |$2}'+'}');
 myContent.value = myContent.value.replace(/(=)[\t\r\n ]*(\{\{s\-rail[^{}]*(?:SNCF|Transilien|RER|Réseau Express Régional|Rhine-Main S-Bahn|RMSB|Milan S Lines|MSR|Pakistan Railways|Nederlandse Spoorwegen)[ ]*\}\}[\t ]*[\r\n]*(?:\{\{s\-(?:rail|line|note)[^{}]*\}\}|[\t ]|[\r\n])*\{\{s\-(?:note|line)[^{}]*\}\})/gi, '$1 {'+'{subst:#invoke:adjacent stations|convert|$2}'+'}');
 myContent.value = myContent.value.replace(/background\-color[ ]*:[ ]*#[ ]*(\{\{)(NYCS|Rhine-Main S-Bahn|RMSB)[_ ]color[_ ]*(\||\}\})/gi, 'background-color:#$1rcr|$2$3');
 myContent.value = myContent.value.replace(/(\{\{)(NYCS|Rhine-Main S-Bahn|RMSB|London Underground|LUL)[_ ]color[_ ]*(\||\}\})/gi, '$1rcr|$2$3');
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*(SNCF|Transilien|RER|Réseau Express Régional|Rhine-Main S-Bahn|RMSB|London Underground|LUL) stations[ ]*(\|)/g, '$1stl|$2$3');
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*(SNCF|Transilien|RER|Réseau Express Régional|Rhine-Main S-Bahn|RMSB|London Underground|LUL) lines?[ ]*\|/g, '$1lnl|$2|');
 myContent.value = myContent.value.replace(/(\{\{rcr\|NYCS)\|default(\}\})/g, '$1$2');
 if (mw.config.get('wgNamespaceNumber') == 0) {
 myContent.value = myContent.value.replace(/<div[ ]*style[ ]*=["' ]*float[ ]*:[ ]*(left|right)['"; ]*>(.*?)<\/div>/g, '{'+'{align|$1|$2}'+'}');
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*[Mm]eta[_ ]*color[_ ]*(\|[^{}\|=]*\}\})/g, '$1party color cell$2');
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*[Mm]eta[_ ]*color[_ ]*(\|[^{}\|=]*\|)[ ]*([0-9]+)[ ]*(\}\})/g, '$1party color cell$2$3px$4');
 myContent.value = myContent.value.replace(/([\r\n][\|!](?:(?:width|(?:row|col)span)[ ]*=[" ]*[0-9]+[" ]*| )*)style[ ]*=['" ]*background(?:\-color|)[ ]*:[ ]*(\{\{[_ ]*[Pp]arty[_ ]*color)[_ ]*(\|[^{}=\|]*\}\})[;'" ]*\|/g, "$1$2 cell$3");
 myContent.value = myContent.value.replace(/([\r\n][\|!](?:(?:width|(?:row|col)span)[ ]*=[" ]*[0-9]+[" ]*| )*)bgcolor[ ]*=['" ]*(\{\{[_ ]*[Pp]arty[_ ]*color)[_ ]*(\|[^{}=\|]*\}\})['" ]*\|/g, "$1$2 cell$3");
 myContent.value = myContent.value.replace(/width[ ]*=[ ]*([0-9]+)[ ]*((?:rowspan[^{}\|]*|colspan[^{}\|]*)*\{\{party color cell\|[^{}\|]*)(\}\})/g, '$2|$1px$3');
 }
 if( myContent.value.search(/<!--[ ]*convert[ ]*-->/gi) >= 0 ) {
 myContent.value = myContent.value.replace(/([\r\n]\|[ ]*style[^\|\r\n]*\|)(-)/g, '$1 $2');
 if( myContent.value.search(/Harris/gi) >= 0 && myContent.value.search(/BCS/gi) >= 0 && myContent.value.search(/AP/gi) >= 0 && myContent.value.search(/Coaches/gi) >= 0) {
 myContent.value = myContent.value.replace(/\{\|[^\r\n]*[\r\n]\|\+[\t ]*Ranking[\t ]+Movement[^\r\n]*([\r\n])/gi, '{' + '{NCAA Division I FBS football rankings$1');
 myContent.value = myContent.value.replace(/![ ]*Poll[^\r\n]*Wk ([0-9]+)[ ]*!![ ]*Final/g, '| finalpollweek = {'+'{subst:#expr:$1+1}'+'}');
 myContent.value = myContent.value.replace(/\|\-[^\r\n]*[\r\n]![ ]*(?:AP|\[\[[^\[\]]*\|AP\]\])[ ]*[\r\n]\|[ ]*style[^\r\n\|]*\|[ ]*/g, '| AP_pre = ');
 myContent.value = myContent.value.replace(/(\|[ ]*AP_pre[ ]*=[^\r\n]*[\r\n])\|[ ]*style[^\r\n\|]*\|[ ]*/g, '$1| AP_{'+'{subst:#expr:1}'+'} = ');
 myContent.value = myContent.value.replace(/\|\-[^\r\n]*[\r\n]![ ]*(?:Coaches'?|\[\[[^\[\]]*\|Coaches'?\]\])[ ]*[\r\n]\|[ ]*style[^\r\n\|]*\|[ ]*/g, '| coaches_pre = ');
 myContent.value = myContent.value.replace(/(\|[ ]*coaches_pre[ ]*=[^\r\n]*[\r\n])\|[ ]*style[^\r\n\|]*\|[ ]*/g, '$1| coaches_{'+'{subst:#expr:1}'+'} = ');
 myContent.value = myContent.value.replace(/\|\-[^\r\n]*[\r\n]![ ]*(?:Harris|\[\[[^\[\]]*\|Harris\]\])[ ]*[\r\n]\|[ ]*colspan[ ]*=[" ]*([0-9]+)[" ]*\|[ ]*Not released[ ]*([\r\n])\|[ ]*style[^\|\r\n]*\|[ ]*/g, '| harrisfirstweek = $1$2| harris_{'+'{subst:#expr:$1}'+'} = ');
 myContent.value = myContent.value.replace(/\|\-[^\r\n]*[\r\n]![ ]*(?:BCS|\[\[[^\[\]]*\|BCS\]\])[ ]*[\r\n]\|[ ]*colspan[ ]*=[" ]*([0-9]+)[" ]*\|[ ]*Not released[ ]*([\r\n])\|[ ]*style[^\|\r\n]*\|[ ]*/g, '| bcsfirstweek = $1$2| bcs_{'+'{subst:#expr:$1}'+'} = ');
 } else {
 while( lt != myContent.value ) {
 lt = myContent.value;
 myContent.value = myContent.value.replace(/([\r\n]![ ]*Poll[^\r\n]*)[\r\n]!/g, '$1 !!');
 }
 lt = '';
 myContent.value = myContent.value.replace(/\{\|[^\r\n]*[\r\n]\|\+[\t ]*Ranking[\t ]+Movement[^\r\n]*([\r\n])/gi, '{' + '{Ranking movements$1');
 myContent.value = myContent.value.replace(/![ ]*Poll[^\r\n]*!![ ]*(?:Wk|<br[^<>]*>)*[ ]*([0-9]+)[ ]*!![ ]*Final(?:<br[^<>]*>| )*/g, '| poll1lastweek = {'+'{subst:#expr:$1+1}'+'}');
 myContent.value = myContent.value.replace(/\|\-[^\r\n]*[\r\n]![ ]*([^\r\n]*)[ ]*[\r\n]\|[ ]*(?:style[^\r\n\|]*\||)[ ]*/, '| poll1title = $1\n| poll1_{'+'{subst:#expr:0}'+'} = ');
 myContent.value = myContent.value.replace(/\|\-[^\r\n]*[\r\n]![ ]*([^\r\n]*)[ ]*[\r\n]\|[ ]*(?:style[^\r\n\|]*\||)[ ]*/, '| poll2title = $1\n| poll2_{'+'{subst:#expr:0}'+'} = ');
 myContent.value = myContent.value.replace(/\|\-[^\r\n]*[\r\n]![ ]*([^\r\n]*)[ ]*[\r\n]\|[ ]*(?:style[^\r\n\|]*\||)[ ]*/, '| poll3title = $1\n| poll3_{'+'{subst:#expr:0}'+'} = ');
 myContent.value = myContent.value.replace(/\|\-[^\r\n]*[\r\n]![ ]*([^\r\n]*)[ ]*[\r\n]\|[ ]*(?:style[^\r\n\|]*\||)[ ]*/, '| poll4title = $1\n| poll4_{'+'{subst:#expr:0}'+'} = ');
 if (myContent.value.search(/\|[ ]*poll4title[ ]*=/) >= 0 && myContent.value.search(/\|[ ]*poll4lastweek[ ]*=/) < 0) {
 myContent.value = myContent.value.replace(/(\|[ ]*poll)1(lastweek[ ]*=[ ]*[^\r\n]*[\r\n])/g, '$11$2$14$2');
 }
 if (myContent.value.search(/\|[ ]*poll3title[ ]*=/) >= 0 && myContent.value.search(/\|[ ]*poll3lastweek[ ]*=/) < 0) {
 myContent.value = myContent.value.replace(/(\|[ ]*poll)1(lastweek[ ]*=[ ]*[^\r\n]*[\r\n])/g, '$11$2$13$2');
 }
 if (myContent.value.search(/\|[ ]*poll2title[ ]*=/) >= 0 && myContent.value.search(/\|[ ]*poll2lastweek[ ]*=/) < 0) {
 myContent.value = myContent.value.replace(/(\|[ ]*poll)1(lastweek[ ]*=[ ]*[^\r\n]*[\r\n])/g, '$11$2$12$2');
 }
 }
 while( lt != myContent.value ) {
 lt = myContent.value;
 myContent.value = myContent.value.replace(/(\{\{subst:#expr:[^{}]*\}\}[^\r\n]*?)\|\|/g, '$1\n|');
 myContent.value = myContent.value.replace(/(\|[ ]*[A-Za-z0-9]+_\{\{subst:#expr:[^{}]*)(\}\}[ ]*=)([^\r\n]*[\r\n])\|[ ]*(?:style[^\r\n\|]*\||)[ ]*( \-|[0-9B-Z—\r\n]|\|\|)/g, '$1$2$3$1+1$2 $4');
 }
 myContent.value = myContent.value.replace(/(\{\{subst:#expr:[^{}]*\}\}[ ]*=[^\r\n]*[\r\n])(?:\|\-[^\r\n]*[\r\n]|)\|\}/g, '$1}'+'}');
 myContent.value = myContent.value.replace(/[\r\n]\|\-[^\r\n]*([\r\n]\|[ ]*[A-Za-z]+lastweek[ ]*=)/g, '$1');
 lt = '';
 }
 if( myContent.value.search(/\{\{last edited by\}\}/gi) >= 0) {
 myContent.value = myContent.value.replace(/([^\r\n>])(\{\{[^{}\|]*\}\})/g, '$1<nowiki>$2</nowiki>');
 myContent.value = myContent.value.replace(/(\[\[[^\[\]\r\n]*)<nowiki>(\{\{)([^{}]*\}\})<\/nowiki>/g, '$1{'+'{anchorencode:$2tl|$3}'+'}');
 }
 if (mw.config.get('wgNamespaceNumber') == 0) {
 
 myContent.value = myContent.value.replace(/(<span style="[^<>"]*)"><span style="([^<>]*>[^<>]*<\/span>)<\/span>/g, '$1;$2');
 myContent.value = myContent.value.replace(/<span style="color:white[; ]*">(→)<\/span>/g, '{'+'{0|$1}'+'}');

 myContent.value = myContent.value.replace(/(\{\{)([^{}\|]*)\/meta\/color[ ]*(\}\})/g, '$1party color|$2$3');
 myContent.value = myContent.value.replace(/(\|[ ]*url[ ]*=[ ]*)(http:\/\/web\.archive\.org\/web\/)([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9]+\/)(http[^ \|{}\]\r\n]*)/g, '$1$7|archive-url=$2$3$4$5$6$7|archive-date=$3-$4-$5|url-status=');
 myContent.value = myContent.value.replace(/(\|[ ]*url[ ]*=[ ]*)(http[^\|\r\n{}]*)(\|[ ]*archive\-url[ ]*=[ ]*https?:\/\/web\.archive\.org\/web\/[0-9]+\/)[0-9]+\//g, '$1$2$3$2');
 //myContent.value = myContent.value.replace(/[\r\n]\{\|[^{}]*Overall[ ]+[Rr]ecord[^{}]*[\r\n]\|\}/g, '');
 //myContent.value = myContent.value.replace(/[\r\n]\{\|[^{}]*\{\{[^{}]*Overall[ ]+[Rr]ecord[^{}]*\}\}[^{}]*[\r\n]\|\}/g, '');
 //myContent.value = myContent.value.replace(/[\r\n]\{\|[^{}]*\{\{[^{}]*Overall[ ]+[Rr]ecord[^{}]*\}\}[^{}]*\{\{[^{}]*\}\}[^{}]*[\r\n]\|\}/g, '');
 //myContent.value = myContent.value.replace(/[\r\n]\{\|[^{}]*\{\{[^{}]*Overall[ ]+[Rr]ecord[^{}]*\}\}[^{}]*\{\{[^{}]*\}\}[^{}]*\{\{[^{}]*\}\}[^{}]*[\r\n]\|\}/g, '');
 myContent.value = myContent.value.replace(/([\t ]*[\r\n]*[\t ]*[\r\n]*)([\r\n]\{\{coord[^{}]*\}\})([\t ]*[\r\n]*[\t ]*[\r\n]*)([\r\n]\{\{authority[^{}]*\}\})/gi, '$4$2$1$3');
 myContent.value = myContent.value.replace(/<div[^<>]*>[\t ]*[\r\n]*(\{\{weather box)/gi, '$1|width=auto');
 myContent.value = myContent.value.replace(/\|[ ]*2020[ ]*=[ ]*([0-9,]+)[ ]*[\r\n](\|[ ]*2020[ ]*=[ ]*\1)/g, '$2');
 myContent.value = myContent.value.replace(/([\t ])[\t ][\t ]*([\r\n])/g, '$1$2');
 myContent.value = myContent.value.replace(/([^\|=])[\t ][\t ]*([\r\n])/g, '$1$2');
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*[Ii]nfobox[_ ]+Football[_ ]+club[_ ]+season/gi, '$1Infobox football club season');
 myContent.value = myContent.value.replace(/Infobox[_ ]+International[_ ]+Football[_ ]+Competition/gi, 'Infobox international football competition');
 if( (myContent.value.match(/\{\{[Hh]idden begin/g) || []).length != (myContent.value.match(/\{\{[Hh]idden end/g) || []).length) {
 alert('Number of hidden begin != Number of hidden end');
 }
 if( (myContent.value.match(/\{\{[Cc]ollapse top/g) || []).length != (myContent.value.match(/\{\{[Cc]ollapse bottom/g) || []).length) {
 alert('Number of collapse top != Number of collapse bottom');
 }
 myContent.value = myContent.value.replace(/([\r\n])\|\-[\t ]*([\r\n]\{\{s\-)/g, '$1{'+'{s-break}'+'}$2');
 }
 if (mw.config.get('wgNamespaceNumber') == 10) {
 myContent.value = myContent.value.replace(/([\r\n])[\t ]*\|[ ]*liststyle[ ]*=[ ]*width[ ]*:[ ]*auto[; ]*[\r\n]/g, '$1');
 myContent.value = myContent.value.replace(/[\t ]*\|[ ]*liststyle[ ]*=[ ]*width[ ]*:[ ]*auto[; ]*([\r\n]|\|)/g, '$1');
 myContent.value = myContent.value.replace(/(\|[ ]*liststyle[ ]*=[^{}\|]*)[ ]*width[ ]*:[ ]*auto[; ]*/g, '$1');
 myContent.value = myContent.value.replace(/([\r\n])[\t ]*\|[ ]*evenodd[ ]*=[ ]*swap[ ]*[\r\n]/g, '$1');
 myContent.value = myContent.value.replace(/[\t ]*\|[ ]*evenodd[ ]*=[ ]*swap[ ]*([\r\n]|\|)/g, '$1');
 myContent.value = myContent.value.replace(/\|[ ]*groupstyle[ ]*=[ ]*width[ ]*:([^{}\|;]*)[; ]*([\r\n]|\|)/g, '|groupwidth=$1$2');
 myContent.value = myContent.value.replace(/(\|[ ]*groupstyle[ ]*=[^{}\|]*)width[ ]*:([^{}\|;]*)/g, '|groupwidth=$2$1');
 myContent.value = myContent.value.replace(/(\|[ ]*state[ ]*=[ ]*)(collapsed)/g, '$1<includeonly>$2</includeonly>');
 myContent.value = myContent.value.replace(/(\|[ ]*state[ ]*=[ ]*\{\{\{state)(\|collapsed)/g, '$1<includeonly>$2</includeonly>');
 myContent.value = myContent.value.replace(/(\|[ ]*(?:group[0-9]*|title|base|above|below)style[ ]*=(?:\{\{[^{}]*\}\}|[^{}\|\r\n])*)border:[ ]*([123](?:\.5|)px) [ ]*solid [ ]*([^ ;\r\n]*)/g, '$1{'+'{box-shadow border|a|$3|$2}'+'}');
 myContent.value = myContent.value.replace(/(\|[ ]*(?:group[0-9]*|title|base|above|below)style[ ]*=(?:\{\{[^{}]*\}\}|[^{}\|\r\n])*)border:[ ]*([123](?:\.5|)px) [ ]*([^ ;\r\n]*)[ ]*solid/g, '$1{'+'{box-shadow border|a|$3|$2}'+'}');
 myContent.value = myContent.value.replace(/(\|[ ]*(?:group[0-9]*|title|base|above|below)style[ ]*=(?:\{\{[^{}]*\}\}|[^{}\|\r\n])*)border:[ ]*solid[ ]* ([^ \r\n]*) [ ]*([123](?:\.5|)px)/g, '$1{'+'{box-shadow border|a|$2|$3}'+'}');
 myContent.value = myContent.value.replace(/(\|[ ]*(?:group[0-9]*|title|base|above|below)style[ ]*=(?:\{\{[^{}]*\}\}|[^{}\|\r\n])*)border:[ ]*([^ \r\n]*) [ ]*([123](?:\.5|)px)[ ]*solid/g, '$1{'+'{box-shadow border|a|$2|$3}'+'}');
 myContent.value = myContent.value.replace(/(style[ ]*=)[ ]*;/g, '$1');
 myContent.value = myContent.value.replace(/(style[ ]*=) [ ]*/g, '$1 ');
 myContent.value = myContent.value.replace(/\|[ ]*bodystyle[ ]*=[ ]*width[ ]*:[ ]*\{\{\{width\|[ ]*100\%[ ]*\}\}\}[; ]*[\r\n]/g, '');
 myContent.value = myContent.value.replace(/\{\{box\-shadow border\|[ablrt ]*\|[ ]*(?:white|#fff|#ffffff)[ ]*(?:\|[^{}]*|)\}\}[; ]*/gi, '');
 myContent.value = myContent.value.replace(/([\t ]*\|[ ]*[a-z]*style[ ]*=[^\r\n]*[\r\n])([\t ]*\|[ ]*state[ ]*=[^\r\n]*[\r\n])/g, '$2$1');
 myContent.value = myContent.value.replace(/([\t ]*\|[ ]*[a-z]*style[ ]*=[^\r\n]*[\r\n])([\t ]*\|[ ]*state[ ]*=[^\r\n]*[\r\n])/g, '$2$1');
 myContent.value = myContent.value.replace(/([\t ]*\|[ ]*[a-z]*style[ ]*=[^\r\n]*[\r\n])([\t ]*\|[ ]*name[ ]*=[^\r\n]*[\r\n])/g, '$2$1');
 myContent.value = myContent.value.replace(/(\{\{NFLPrimaryStyle[^{}]*)(\}\})[; ]*\{\{box\-shadow[^{}]*([0-9]+)px\}\}[; ]*/g, '$1|border=$3$2');
 if(myContent.value.search(/(?:group|title|base|above|below)style[ ]*=(?:\{\{(?:\{\{[^{}]*\}\}|[^{}])*\}\}|[^{}]|\{\{\{state[^{}]*\}\}\})*(?:group|title|base|above|below)style/g) >= 0) {
 // alert('Multiple styles?');
 }
 }
 myContent.value = myContent.value.replace(/(![ ]*style[ ]*=[ ]*")[ ]*background(?:\-color|)[ ]*:[ ;]*(")/g, '$1$2');
 myContent.value = myContent.value.replace(/\{\{#if:[ ]*\|[ ]*\|([^{}\|]*)\}\}/g, '$1');
 myContent.value = myContent.value.replace(/\{\{#switch:\{\{lc:no\}\}[^{}]*\|#default=collapsed\}\}/gi, 'collapsed');
 var ot = myContent.value;
 myContent.value = myContent.value.replace(/(class[ ]*=[^\r\n]*navbox[^\r\n]*[\r\n](?:\|\-[^\r\n]*[\r\n]|)![ ]*style[ ]*=[ ]*")/g, '$1background:lavender;');
 myContent.value = myContent.value.replace(/(class[ ]*=[^\r\n]*navbox[^\r\n]*[\r\n](?:\|\-[^\r\n]*[\r\n]|)!)([ ]*[A-Z\['])/g, '$1 style="background:lavender" |$2');
 myContent.value = myContent.value.replace(/class[ ]*=['" ]*navbox['" ]*( style[ ]*=[" ']*)/g, '$1width:100%;background:#fff;font-size:88%;border: 1px solid #a2a9b1;');
 myContent.value = myContent.value.replace(/(class[ ]*=['" ]*(?:toccolours |))navbox ((?:[^\r\n\|\{\}]|\{\{\{[^{}]*\}\}\})*style[ ]*=[" ']*)/g, '$1$2width:100%;background:#fff;font-size:88%;border: 1px solid #a2a9b1;');
 myContent.value = myContent.value.replace(/(class[ ]*=['" ]*(?:toccolours |))navbox ((?:[^\r\n\|\{\}]|\{\{\{[^{}]*\}\}\})*)/g, '$1$2 style="width:100%;background:#fff;font-size:88%;border: 1px solid #a2a9b1;"');
 myContent.value = myContent.value.replace(/([\r\n]\|[ ]*[a-z]+)class([ ]*=[ ]*)navbox\-title[\t ]*([\r\n])/g, '$1style$2background:#ccccff;$3');
 myContent.value = myContent.value.replace(/([\r\n]\|[ ]*[a-z]+)class([ ]*=[ ]*)navbox\-abovebelow[\t ]*([\r\n])/g, '$1style$2background:#ddddff;$3');
 myContent.value = myContent.value.replace(/([\r\n]\|[\t ]*[a-z]+)class([ ]*=[ ]*)([\t a-z\-]+)[\t ]+navbox\-title[\t ]*([\r\n])/g, '$1class$2$3$1style$2background:#ccccff;$4');
 myContent.value = myContent.value.replace(/([\r\n]\|[\t ]*[a-z]+)class([ ]*=[ ]*)([\t a-z\-]+)[\t ]+navbox\-abovebelow[\t ]*([\r\n])/g, '$1class$2$3$1style$2background:#ddddff;$4');
 myContent.value = myContent.value.replace(/(\|[ ]*headingstyle[ ]*=[ ]*background:[^\r\n]*)[\r\n]\|[ ]*headingstyle[ ]*=[ ]*(border-bottom:)([^;\r\n]*)/g, '$1; border-top:$3; $2$3');
 myContent.value = myContent.value.replace(/(\|[ ]*)([a-z]+)(style[ ]*=[ ]*[a-z][^\r\n\|]*)[\r\n]\|[ ]*\2style[ ]*=[ ]*([a-z]+)/g, '$1$2$3;$4');
 myContent.value = myContent.value.replace(/(;)(;">(?:wood|super))/g, '$1<!--' + 'GM MARK-->$2');
 myContent.value = myContent.value.replace(/(style[ ]*=[^\|\r\n]*;)[ ]*;/g, '$1');
 myContent.value = myContent.value.replace(/;;/g, ';;');
 myContent.value = myContent.value.replace(/<!--[ ]*GM[ ]*MARK[ ]*-->/gi, '');
 myContent.value = myContent.value.replace(/class[ ]*=["' ]*navbox\-title["' ]*(style[ ]*=[ ]*")/g, '$1background-color:#ccf;');
 myContent.value = myContent.value.replace(/class[ ]*=["' ]*navbox\-abovebelow["' ]*(style[ ]*=[ ]*")/g, '$1background-color:#ddf;');
 myContent.value = myContent.value.replace(/\{\|[^\r\n]*navbox mw\-collapsible autocollapse[^\r\n]*[\r\n](?:\|\-[^\r\n]*[\r\n]|)![^\r\n]*\{\{[Tt]?[Nn]avbar\-collapsible[ ]*\|((?:\{\{[^{}]*\}\}|\[\[[^\[\]]*\]\]|[^{}\|\[\]])*)(?:\|[^{}\|]*|)\}\}[\t ]*/g, '{'+'{navbox top\n| name = {'+'{subst:#invoke:string|replace|'+'{'+'{subst:PAGENAME}'+'}|&#39;|\'}'+'}\n\| title = $1\n| state = {{{state|}}}\n| bodyclass = hlist\n}'+'}\n{| style="width:100%" class="wraplinks"');
 myContent.value = myContent.value.replace(/\{\|[^\r\n]*navbox mw\-collapsible[^\r\n]*[\r\n](?:\|\-[^\r\n]*[\r\n]|)![^\r\n]*\{\{[Tt]?[Nn]avbar\-collapsible[ ]*\|((?:\{\{[^{}]*\}\}|\[\[[^\[\]]*\]\]|[^{}\|\[\]])*)(?:\|[^{}\|]*|)\}\}[\t ]*/g, '{'+'{navbox top\n| name = {'+'{subst:#invoke:string|replace|'+'{'+'{subst:PAGENAME}'+'}|&#39;|\'}'+'}\n\| title = $1\n| state = {{{state<includeonly>|collapsed</includeonly>}}}\n| bodyclass = hlist\n}'+'}\n{| style="width:100%" class="wraplinks"');

 myContent.value = myContent.value.replace(/((?:!|<th)[ ]*)class="navbox\-title"([ ]*(?:>|\|))/g, '$1style="background:#ccf"$2');
 if( ot != myContent.value) {
 var editsummary = document.getElementsByName('wpSummary')[0];
 editsummary.value = 'format css';
 }
 myContent.value = myContent.value.replace(/([;'"])[ ]*border[ ]*:[^;'"\|\r\n<>]*;((?:[^'"\|\r\n<>]*;|)[ ]*border[ ]*:)/g, '$1$2');
 myContent.value = myContent.value.replace(/([;'"])[ ]*background(?:\-color|)[ ]*:[^;'"\|\r\n<>]*;((?:[^'"\|\r\n<>]*;|)[ ]*background(?:\-color|)[ ]*:)/g, '$1$2');
 myContent.value = myContent.value.replace(/([;'"])[ ]*width[ ]*:[^;'"\|\r\n<>]*;((?:[^'"\|\r\n<>]*;|)[ ]*width[ ]*:)/g, '$1$2');
 myContent.value = myContent.value.replace(/([;'"])[ ]*font\-size[ ]*:[^;'"\|\r\n<>]*;((?:[^'"\|\r\n<>]*;|)[ ]*font\-size[ ]*:)/g, '$1$2');

 if( (myContent.value.match(/\{\{[Nn]avbox top/g) || []).length > (myContent.value.match(/\{\{[Nn]avbox bottom/g) || []).length) {
 myContent.value = myContent.value.replace(/(\|\})[\t \r\n]*(<noinclude>)/g, '$1\n{'+'{navbox bottom}'+'}$2');
 }
 if( (myContent.value.match(/\{\{[Nn]avbox top/g) || []).length > (myContent.value.match(/\{\{[Nn]avbox bottom/g) || []).length) {
 myContent.value = myContent.value.replace(/(<noinclude>)/g, '\n{'+'{navbox bottom}'+'}$1');
 }
 if( (myContent.value.match(/\{\{[Nn]avbox top/g) || []).length != (myContent.value.match(/\{\{[Nn]avbox bottom/g) || []).length) {
 alert('Number of navbox top != Number of navbox bottom');
 }
 
 if (mw.config.get('wgNamespaceNumber') == 6 ) {
 myContent.value = myContent.value.replace(/\{\{\{[^{}\|]*\|([^\{\}\|]*)\}\}\}/g, '$1');
 myContent.value = myContent.value.replace(/(\{\{)[\t ]*(#)/g, '$1subst:$2');
 }
 
 var sections = myContent.value.split(/(<!--|-->|<pre|<\/pre>|<nowiki|<\/nowiki>|<syntaxhighlight|<\/syntaxhighlight>|<math|<\/math>)/g);
 // begin convoluted loop
 var i=0;
 function myDivLoop() {
 if ( sections[i].search(/(<!--|<pre|<nowiki|<syntaxhighlight|<math)/g) >= 0 ) {
 if ((i+2) < sections.length) {
 sections[i] = sections[i] + sections[i+1] + sections[i+2];
 sections[i+1] = '';
 sections[i+2] = '';
 } else if ((i+2) < sections.length) {
 sections[i] = sections[i] + sections[i+1];
 sections[i+1] = '';
 }
 } else {
 sections[i] = sections[i].replace(/(<div[\t ])([^<>\|]+)(class[\t ]*=[" ]*Nav(?:Frame|Head|Content)[^\|<>]*)(>)/g, '$1$3$2$4');
 sections[i] = sections[i].replace(/(<div[\t ]+class[\t ]*=[" ]*Nav(?:Frame|Head|Content)(?:[\t ]+collapsed|)[\t ]*['"])[\t ]([^<>\|]+)(style[\t ]*=[^\|<>]*)(>)/g, '$1 $3 $2$4');
 sections[i] = sections[i].replace(/(<div[\t ]+class[\t ]*=[" ]*Nav[^<>\r\n\|]*)[\r\n]/g, '$1 ');
 sections[i] = sections[i].replace(/(<div[\t ]+class[\t ]*=[" ]*Nav[^<>\r\n\|]*)[\r\n]/g, '$1 ');
 sections[i] = sections[i].replace(/(<div)[\t ]+class[\t ]*=[" ]*(Nav(?:Frame|Head|Content)(?:[\t ]+collapsed|))[" ]*((?: align[ ]*=[ "]*(?:left|right|center)[" ]*|)>)/g, '$1 class="$2" style=""$3');
 sections[i] = sections[i].replace(/(<div)[\t ]*class[\t ]*=[\t" ]*NavFrame collapsed[\t" ]*style[\t ]*=[\t ]*"/g, '$1 class="mw-collapsible mw-collapsed" style="text-align: center; padding: 4px; border: 1px solid #a2a9b1; font-size: 95%;');
 sections[i] = sections[i].replace(/(<div)[\t ]*class[\t ]*=[\t" ]*NavFrame[\t" ]*style[\t ]*=[\t ]*"/g, '$1 class="mw-collapsible" style="text-align: center; padding: 4px; border: 1px solid #a2a9b1; font-size: 95%;');
 sections[i] = sections[i].replace(/(<div)[\t ]*class[\t ]*=[\t" ]*NavHead[\t" ]*style[\t ]*=[\t ]*"/g, '$1 style="line-height: 1.6em; font-weight: bold; text-align: center; background-color: #ccf;');
 sections[i] = sections[i].replace(/(<div)[\t ]*class[\t ]*=[\t" ]*NavContent[\t" ]*style[\t ]*=[\t ]*"/g, '$1 class="mw-collapsible-content" style="font-size:100%;');
 // Style cleaner
 for(var sci=0; sci<4; sci++) {
 sections[i] = sections[i].replace(/(style[ ]*=[^\r\n\|\{\}<>"']*(?:"|;))[\t ]*([a-z\-]+)[\t ]*:[^<>"';\|]*;((?:[^"'<>\|]*;|)[\t ]*\2[ ]*:)/g, '$1$3');
 sections[i] = sections[i].replace(/(style[ ]*=[^\r\n\|\{\}<>"']*(?:"|;))[\t ]*background(?:\-color|)[\t ]*:[^<>"';\|]*;([^'"<>\|]*background(?:\-color|)[ ]*:)/g, '$1$2');
 }
 }
 i++;
 if(i<sections.length) {
 myDivLoop();
 }
 }
 if (mw.config.get('wgNamespaceNumber') != 2 ) {
 myDivLoop();
 // end convoluted loop
 myContent.value = sections.join('');
 }

 myContent.value = myContent.value.replace(/wikitable[ ]+gauche/g, 'wikitable');
 myContent.value = myContent.value.replace(/(\{\|[^\r\n]*[\r\n](?:\|\-[^\r\n]*[\r\n]|))\|([^\r\n]*Team 1[^\r\n]*[\r\n])\|([^\r\n]*(?:Team 2|Score)[^\r\n]*[\r\n])\|([^\r\n]*(?:Result|Team 2)[^\r\n]*[\r\n])/gi, '$1!$2!$3!$4<!-- GM IN HEADING -->');
 myContent.value = myContent.value.replace(/(<!-- GM IN HEADING -->)\|([^\-\}\r\n][^\r\n]*[\r\n])/gi, '!$2$1');
 myContent.value = myContent.value.replace(/(<!-- GM IN HEADING -->)\|([^\-\}\r\n][^\r\n]*[\r\n])/gi, '!$2$1');
 myContent.value = myContent.value.replace(/(<!-- GM IN HEADING -->)\|([^\-\}\r\n][^\r\n]*[\r\n])/gi, '!$2$1');
 myContent.value = myContent.value.replace(/<!-- GM IN HEADING -->(\|[\-\}])/gi, '$1');
 
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*election[_ ]*table/g, '$1election table');
 myContent.value = myContent.value.replace(/(\{\{[_ ]*election[_ ]*table[^{}]*)'''/g, '$1');
 myContent.value = myContent.value.replace(/(\{\{[_ ]*election[_ ]*table[^{}]*)'''/g, '$1');
 myContent.value = myContent.value.replace(/(\{\{election table[^\r\n]*[\r\n])(?:\|\-[^\r\n]*[\r\n]|)(![^\r\n]*) style[ ]*=[" ]*text\-align[ ]*:[ ]*center[;" ]*(\|[^\r\n]*[\r\n])/g, '$1|-\n$2$3<!-- GM IN HEADER -->');
 myContent.value = myContent.value.replace(/(<!-- GM IN HEADER -->)(![^\r\n]*) style[ ]*=[" ]*text\-align[ ]*:[ ]*center[;" ]*(\|[^\r\n]*[\r\n])/g, '$2$3$1');
 myContent.value = myContent.value.replace(/(<!-- GM IN HEADER -->)(![^\r\n]*) style[ ]*=[" ]*text\-align[ ]*:[ ]*center[;" ]*(\|[^\r\n]*[\r\n])/g, '$2$3$1');
 myContent.value = myContent.value.replace(/(<!-- GM IN HEADER -->)(![^\r\n]*) style[ ]*=[" ]*text\-align[ ]*:[ ]*center[;" ]*(\|[^\r\n]*[\r\n])/g, '$2$3$1');
 myContent.value = myContent.value.replace(/(<!-- GM IN HEADER -->)(![^\r\n]*) style[ ]*=[" ]*text\-align[ ]*:[ ]*center[;" ]*(\|[^\r\n]*[\r\n])/g, '$2$3$1');
 myContent.value = myContent.value.replace(/(<!-- GM IN HEADER -->)(![^\r\n]*) style[ ]*=[" ]*text\-align[ ]*:[ ]*center[;" ]*(\|[^\r\n]*[\r\n])/g, '$2$3$1');
 myContent.value = myContent.value.replace(/(<!-- GM IN HEADER -->)(\|\-)[^\r\n]*([\r\n])\|[ ]*style[ ]*=[" ]*text\-align[ ]*:[ ]*center[;" ]*\|[ ]*'''(#|Votes|%)[' ]*([\r\n])/g, '$2$3! $4$5$1');
 myContent.value = myContent.value.replace(/(<!-- GM IN HEADER -->)\|[ ]*style[ ]*=[" ]*text\-align[ ]*:[ ]*center[;" ]*\|[ ]*'''(#|Votes|%|±%)[' ]*([\r\n])/g, '! $2$3$1');
 myContent.value = myContent.value.replace(/(<!-- GM IN HEADER -->)\|[ ]*style[ ]*=[" ]*text\-align[ ]*:[ ]*center[;" ]*\|[ ]*'''(#|Votes|%|±%)[' ]*([\r\n])/g, '! $2$3$1');
 myContent.value = myContent.value.replace(/(<!-- GM IN HEADER -->)\|[ ]*style[ ]*=[" ]*text\-align[ ]*:[ ]*center[;" ]*\|[ ]*'''(#|Votes|%|±%)[' ]*([\r\n])/g, '! $2$3$1');
 myContent.value = myContent.value.replace(/<!-- GM IN HEADER -->(\|-|\{\{Canadian)/g, '$1');
 myContent.value = myContent.value.replace(/([a-z]+)[\t \|]*\|[ ]*(?:title|base|group)style[ ]*=[ ]*background:paleturquoise[; ]*\{\{box[^{}]*\}\}[; ]*[\r\n]?/gi, '$1\n');
 myContent.value = myContent.value.replace(/[\t \|]*\|[ ]*(?:title|base|group)style[ ]*=[ ]*background:paleturquoise[; ]*\{\{box[^{}]*\}\}[; ]*[\r\n]?/gi, '');
 if (mw.config.get('wgNamespaceNumber') == 0 ) {
 myContent.value = myContent.value.replace(/(==[ ]*External links[ ]*==(?:[\t ]*[\r\n]|\*[^\r\n]*[\r\n])*)(==[ ]*References[ ]*==(?:[\t ]*[\r\n]|<ref[^\r\n]*[\r\n]|\{\{ref[^\r\n]*[\r\n])*)(\{\{DEFAULTSORT|\{\{s\-|\[\[Category)/gim, '$2$1$3');
 if(myContent.value.search(/<!--[ ]*GM KBR/g) < 0) {
 myContent.value = myContent.value.replace(/(\{\{(?:Kickboxing|Fight) record start(?:\{\{[^{}]*\}\}|[^{}])*\}\})/gi, '$1<!--GM KBR TABLE-->');
 }
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*election[_ ]*table[_ ]*\|?[\t ]*\|[\t ]*editlink[ ]*=[ ]*no[\t ]*(\}\})/g, '$1election table$2');
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*election[_ ]*table[_ ]*(\}\})([^\r\n][^\r\n]*)/gi, '$1election table|title=$3$2');
 myContent.value = myContent.value.replace(/(\{\{[_ ]*election[_ ]*table[_ ]*\|[^{}]*)'''/g, '$1');
 myContent.value = myContent.value.replace(/(\{\{[_ ]*election[_ ]*table[_ ]*\|[^{}]*)'''/g, '$1');
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*election[_ ]*table[_ ]*\|\|''([^{}]*)''(\}\})/g, '$1election table|title=$2$3');
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*election[_ ]*table[_ ]*\|[^\|\{\}=]*(\}\}[\t ]*[\r\n]\|)/gi, '$1election table|editlink=no$2');
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*election[_ ]*table[_ ]*\|[^\|\{\}=]*(\}\})[\r\n\t ]*\'\'\'([^\r\n]*)\'\'\'/gi, '$1election table|editlink=no|title=$3$2');
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*election[_ ]*table[_ ]*\|[^\|\{\}=]*(\}\})[\r\n\t ]*\'\'\'([^\r\n]*)/gi, '$1election table|editlink=no|title=$3$2');
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*election[_ ]*table[_ ]*\|[^\|\{\}=]*(\}\})[\r\n\t ]*([^\r\n\'\t \|][^\r\n]*)/gi, '$1election table|editlink=no|title=$3$2');
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*election[_ ]*table[_ ]*\|[^\|\{\}=]*\|[ ]*([A-Za-z\[])/gi, '$1election table|editlink=no|title=$2');
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*election[_ ]*table[_ ]*\|[ ]*editlink[ ]*=[ ]*no[ ]*\|[ ]*2[ ]*=/gi, '$1election table|editlink=no|title=');
 myContent.value = myContent.value.replace(/(\{\{[_ ]*election[_ ]*table[_ ]*[^{}]*\|)title[ ]*=[ ]*(sortable[ ]*=)/gi, '$1$2');
 myContent.value = myContent.value.replace(/\|editlink=no/g, '');
 if( myContent.value.search(/\{\{[_ ]*TVQ[_ ]*\|[^{}]*\}\}/gi) >= 0) {
 var mm = myContent.value.match(/(\{\{[_ ]*TVQ[_ ]*\|[^{}]*\}\})/gi);
 for(k=0; k<mm.length; k++) {
 var m = mm[k];
 var id = m.replace(/\{\{[_ ]*TVQ[_ ]*\|([^{}\|]*)(?:\|[^{}]*|)\}\}/gi, '$1');
 var r = m.replace(/(\{\{)[_ ]*TVQ[_ ]*\|/gi, '$1FCC-LMS-Facility||');
 r = prompt('FCC facility id for ' + id, r);
 if (r && r != '' ) {
 r = r.replace(/^([A-Z\-][A-Z0-9\-]*)[\t ][\t ]*([0-9]+)[\t ]*$/g, '{'+'{FCC-LMS-Facility|$2|$1}'+'}');
 var re = new RegExp( '\\{\\{[_ ]*TVQ[_ ]*\\|' + id + '(?:\\|[^{}]*|)\\}\\}', 'gi');
 myContent.value = myContent.value.replace(re, r);
 myContent.value = myContent.value.replace(/(\{\{FCC\-LMS\-Facility[^{}]*)[\t ]/g, '$1');
 myContent.value = myContent.value.replace(/(\{\{FCC\-LMS\-Facility[^{}]*)[\t ]/g, '$1');
 myContent.value = myContent.value.replace(/(\{\{FCC\-LMS\-Facility[^{}]*)[\t ]/g, '$1');
 }
 }
 }
 myContent.value = myContent.value.replace(/!style="border-style: none none solid solid; background: #e3e3e3"[ ]*\|/g, '|');
 if( myContent.value.search(/\|-[^\r\n]*[\r\n]\|[' ]*Result[\t' ]*[\r\n]\|[' ]*Record[\t' ]*[\r\n]\|[' ]*Opponent[\t' ]*[\r\n]\|[' ]*Method[\t' ]*[\r\n]\|[' ]*Event[\t' ]*[\r\n]\|[' ]*Date[\t' ]*[\r\n]\|[' ]*Round[\t' ]*[\r\n]\|[' ]*Time[\t' ]*[\r\n]\|[' ]*Location[\t' ]*[\r\n]/g) >= 0) {
 myContent.value = myContent.value.replace(/([\r\n]\|)[\t ]*([\r\n])/g, '$1 $2');
 myContent.value = myContent.value.replace(/(\|-[^\r\n]*[\r\n])(\|[^\r\n\-][^\r\n]*[\r\n])(\|[^\r\n\-][^\r\n]*[\r\n])(\|[^\r\n\-][^\r\n]*[\r\n])(\|[^\r\n\-][^\r\n]*[\r\n])(\|[^\r\n\-][^\r\n]*[\r\n])(\|[^\r\n\-][^\r\n]*[\r\n])(\|[^\r\n\-][^\r\n]*[\r\n]\|[^\r\n]*[\r\n])(\|[^\r\n\-][^\r\n]*[\r\n])/g, '$1$7$2$4$6$9$5$8$3');
 alert('Check table transformation');
 }
 if( myContent.value.search(/\|-[^\r\n]*[\r\n]\|[' ]*Result[\t' ]*[\r\n]\|[' ]*Opponent[\t' ]*[\r\n]\|[' ]*Method[\t' ]*[\r\n]\|[' ]*Event[\t' ]*[\r\n]\|[' ]*Date[\t' ]*[\r\n]\|[' ]*Round[\t' ]*[\r\n]\|[' ]*Time[\t' ]*[\r\n]\|[' ]*Location[\t' ]*[\r\n]/g) >= 0) {
 myContent.value = myContent.value.replace(/([\r\n]\|)[\t ]*([\r\n])/g, '$1 $2');
 myContent.value = myContent.value.replace(/(\|-[^\r\n]*[\r\n])(\|[^\r\n\-][^\r\n]*[\r\n])(\|[^\r\n\-][^\r\n]*[\r\n])(\|[^\r\n\-][^\r\n]*[\r\n])(\|[^\r\n\-][^\r\n]*[\r\n])(\|[^\r\n\-][^\r\n]*[\r\n])(\|[^\r\n\-][^\r\n]*[\r\n]\|[^\r\n]*[\r\n])(\|[^\r\n\-][^\r\n]*[\r\n])/g, '$1$6$2$3$5$8$4$7');
 alert('Check table transformation');
 }
 myContent.value = myContent.value.replace(/(<span[^<>]*>[^<>\r\n]*<ref[^<>]*>[^<>\r\n]*)[\r\n]/g, '$1 ');
 myContent.value = myContent.value.replace(/(<span[^<>]*>[^<>\r\n]*<ref[^<>]*>[^<>\r\n]*)[\r\n]/g, '$1 ');
 myContent.value = myContent.value.replace(/(<span[^<>]*>[^<>\r\n]*<ref[^<>]*>[^<>\r\n]*)[\r\n]/g, '$1 ');
 myContent.value = myContent.value.replace(/(<span[^<>]*>[^<>\r\n]*<ref[^<>]*>[^<>\r\n]*)[\r\n]/g, '$1 ');
 myContent.value = myContent.value.replace(/(<span[^<>]*>[^<>\r\n]*<ref[^<>]*>[^<>\r\n]*)[\r\n]/g, '$1 ');
 myContent.value = myContent.value.replace(/(<span[^<>]*>[^<>\r\n]*<ref[^<>]*>[^<>\r\n]*)[\r\n]/g, '$1 ');

 myContent.value = myContent.value.replace(/\{\|[^\r\n]*toccolours[^\r\n]*%[^\r\n]*[\r\n](?:\|\-[^\r\n]*[\r\n]|)![^\r\n]*(?:darkGr[ae]y|A9A9A9)[^\r\n]*<span[^<>]*>((?:<ref>.*?<\/ref>|[^<>])*)<\/span>/gi, '{'+'{Fight record start|title=$1}'+'}<!--GM KBR-->');
 myContent.value = myContent.value.replace(/(\}\})<!--GM KBR-->[\t ]*[\r\n](?:\|\-[^\r\n]*[\r\n]|)\|[ ]*[\r\n]*<div[^<>]*>[\t \r\n]*<div[^<>]*>[\t ]*(?:<span[^<>]*>|)((?:<ref>.*?<\/ref>|[^<>])*)(?:<\/span>|)[\t \r\n]*<\/div>/g, '|record=$2$1<!--GM KBR-->');
 myContent.value = myContent.value.replace(/<!--GM KBR-->[\t ]*[\r\n](?:<div[^<>]*>[\t ]*[\r\n]*|)\{\|[^\r\n]*/g, '<!--GM KBR DATE-->');
 myContent.value = myContent.value.replace(/<!--GM KBR DATE-->[\t ]*([\r\n])(?:\|\-[^\r\n]*[\r\n]|)(?:(?:\|[ ]*style[ ]*=[^\|\r\n]*|)\|[ \']*|![ ]*)Date[ \']*(?:!!|\|\||[\t ]*[\r\n]\|)/gi, '<!--GM KBR RESULT-->$1|');
 myContent.value = myContent.value.replace(/<!--GM KBR RESULT-->[\t ]*([\r\n])(?:\|\-[^\r\n]*[\r\n]|)(?:(?:\|[ ]*style[ ]*=[^\|\r\n]*|)\|[ \']*|![ ]*)Result[ \']*(?:!!|\|\||[\t ]*[\r\n]\|)/gi, '<!--GM KBR OPP-->$1|');
 myContent.value = myContent.value.replace(/<!--GM KBR OPP-->[\t ]*([\r\n])(?:\|\-[^\r\n]*[\r\n]|)(?:\|[ ]*style[ ]*=[^\|\r\n]*|)\|[ \']*Opponent[ \']*(?:!!|\|\||[\t ]*[\r\n]\|)/gi, '<!--GM KBR EVENT-->$1|');
 myContent.value = myContent.value.replace(/(\{\{(?:Kickboxing|Fighting|Fight) record start)([^\r\n]*<!--GM KBR Event-->[\t ]*[\r\n]\|)[' ]*Venue[' ]*/gi, '$1|event_type=Venue$2 Event');
 myContent.value = myContent.value.replace(/<!--GM KBR EVENT-->[\t ]*([\r\n])(?:\|\-[^\r\n]*[\r\n]|)(?:\|[ ]*style[ ]*=[^\|\r\n]*|)\|[ \']*Event[ \']*(?:!!|\|\||[\t ]*[\r\n]\|)/gi, '<!--GM KBR LOC-->$1|');
 myContent.value = myContent.value.replace(/<!--GM KBR LOC-->[\t ]*([\r\n])(?:\|\-[^\r\n]*[\r\n]|)(?:\|[ ]*style[ ]*=[^\|\r\n]*|)\|[ \']*Location[ \']*(?:!!|\|\||[\t ]*[\r\n]\|)/gi, '<!--GM KBR METHOD-->$1|');
 myContent.value = myContent.value.replace(/<!--GM KBR METHOD-->[\t ]*([\r\n])(?:\|\-[^\r\n]*[\r\n]|)(?:\|[ ]*style[ ]*=[^\|\r\n]*|)\|[ \']*Method[ \']*(?:!!|\|\||[\t ]*[\r\n]\|)/gi, '<!--GM KBR ROUND-->$1|');
 myContent.value = myContent.value.replace(/<!--GM KBR ROUND-->[\t ]*([\r\n])(?:\|\-[^\r\n]*[\r\n]|)(?:\|[ ]*style[ ]*=[^\|\r\n]*|)\|[ \']*Round[ \']*(?:!!|\|\||[\t ]*[\r\n]\|)/gi, '<!--GM KBR TIME-->$1|');
 myContent.value = myContent.value.replace(/(\{\{(?:Kickboxing|Fighting|Fight) record start)([^\r\n]*<!--GM KBR TIME-->[\t ]*[\r\n])(\|\-)/gi, '$1|notime=y$2| Time\n$3');
 myContent.value = myContent.value.replace(/<!--GM KBR TIME-->[\t ]*([\r\n])(?:\|\-[^\r\n]*[\r\n]|)\|[ \']*Time[ \']*(?:!!|\|\||[\t ]*[\r\n]*[\t ]*[\r\n]\|)/gi, '<!--GM KBR RECORD-->$1|');
 myContent.value = myContent.value.replace(/(\{\{(?:Kickboxing|Fighting|Fight) record start)([^\r\n]*<!--GM KBR RECORD-->[\t ]*[\r\n])(\|\-)/gi, '$1|norec=y$2| Record\n$3');
 myContent.value = myContent.value.replace(/(\{\{)(?:[Kk]ickboxing|[Ff]ight(?:ing|)) (record start)/g, '$1Fight $2');
 myContent.value = myContent.value.replace(/(\{\{)[Ff]ight(?:ing|) (record start[^{}]*ickboxing)/g, '$1Kickboxing $2');
 myContent.value = myContent.value.replace(/(\{\{)[Ff]ighting record start/g, '$1Fight record start');
 myContent.value = myContent.value.replace(/<!--GM KBR RECORD-->[\t ]*([\r\n])(?:\|\-[^\r\n]*[\r\n]|)\|[ \']*Record[ \']*(?:\|\||[\t ]*[\r\n]\|)/gi, '<!--GM KBR TABLE-->$1|');
 myContent.value = myContent.value.replace(/(\|[ ]*)<span style="display:none[; ]*"[ ]*>([^<>=]*)<\/span>/g, '$1{' + '{hs|$2}' + '}');
 myContent.value = myContent.value.replace(/<div[ ]*class[ ]*=[" ]*NavFrame[ ]*collapsed[" ]*>[\t \r\n]*<div class[ ]*=[" ]*NavHead[" ]*style[ ]*=[" ]*([a-z][^<>"]*)[" ]*>([^<>]*)<\/div>[\t\r\n ]*<div[^<>]*>/g, '{' + '{collapse top|style=$1|title=$2}' + '}<!--GM HIDDEN-->');
 myContent.value = myContent.value.replace(/(\{\{collapse top[^{}]*\|)[ ]*style[ ]*=[ ]*(?:background|background\-color)[ ]*:([^\|;{}]*)[; ]+color[ ]*:([^\|;{}]*)[; ]*(\|)/g, '$1bg=$2|fc=$3$4');
 myContent.value = myContent.value.replace(/([\r\n])(![^\r\n]*\{\{College(?:Primary|Secondary)Style[^{}]*\}\}[^\r\n]*)(?:!!|\|\|)/g, '$1$2$1!');
 myContent.value = myContent.value.replace(/(\{\{College)([^{}]*\}\}[^\r\n]*(?:Helmet|Jersey|Pants))/gi, '$1<!--' + 'GM MARK-->$2');
 if(myContent.value.search(/hockey/gi) >=0 ) {
 myContent.value = myContent.value.replace(/\|\-(?:align[ ]*=[" ]*center[" ]*|[\t \|])*style[ ]*=(?:text\-align[ ]*:[ ]*center[; ]*|[ "])*(\{\{College(?:Primary|Secondary))Style\|([^{}\|]*)(?:\|color[^{}\|!]*|\|[ ]*border[ ]*=[ ]*[0-9]+|[\t ])*(\}\})[;" ]*([\r\n])/g, '$1Header|border=2|team=$2$3<!--GM TOP-->$4|-$4');
 myContent.value = myContent.value.replace(/([\r\n](?:\|\-|\{\||\|\+)[^\r\n]*[\r\n])![\t ]*style[ ]*=[" ]*(\{\{College(?:Primary|Secondary))Style\|([^{}\|!]*)(?:\|color[^{}\|!]*|\|[ ]*border[ ]*=[ ]*(?:[0-9]+|no)|[\t ])*(\}\})[;" ]*\|([^\r\n!]*)([\r\n])/g, '$1$2Header|border=2|team=$3$4<!--GM TOP-->$6|-$6! $5$6');
 } else {
 myContent.value = myContent.value.replace(/\|\-(?:align[ ]*=[" ]*center[" ]*|[\t \|])*style[ ]*=(?:text\-align[ ]*:[ ]*center[; ]*|[ "])*(\{\{College(?:Primary|Secondary))Style\|([^{}\|]*)(?:\|color[^{}\|!]*|\|[ ]*border[ ]*=[ ]*[0-9]+|[\t ])*(\}\})[;" ]*([\r\n])/g, '$1Header|team=$2$3<!--GM TOP-->$4|-$4');
 myContent.value = myContent.value.replace(/([\r\n](?:\|\-|\{\||\|\+)[^\r\n]*[\r\n])![\t ]*style[ ]*=[" ]*(\{\{College(?:Primary|Secondary))Style\|([^{}\|!]*)(?:\|color[^{}\|!]*|\|[ ]*border[ ]*=[ ]*(?:[0-9]+|no)|[\t ])*(\}\})[;" ]*\|([^\r\n!]*)([\r\n])/g, '$1$2Header|team=$3$4<!--GM TOP-->$6|-$6! $5$6');
 }
 myContent.value = myContent.value.replace(/(\{\{College(?:Primary|Secondary)Header[^{}]*)(\}\})[\t ]*([\r\n])!([^\r\n\|!]*)(?:!!|\|\|)/g, '$1|$4$2$3!');
 myContent.value = myContent.value.replace(/(\{\{College(?:Primary|Secondary)Header[^{}]*)(\}\})[\t ]*([\r\n])!([^\r\n\|!]*)(?:!!|\|\|)/g, '$1|$4$2$3!');
 myContent.value = myContent.value.replace(/(\{\{College(?:Primary|Secondary)Header[^{}]*)(\}\})[\t ]*([\r\n])!([^\r\n\|!]*)(?:!!|\|\|)/g, '$1|$4$2$3!');
 myContent.value = myContent.value.replace(/(\{\{College(?:Primary|Secondary)Header[^{}]*)(\}\})[\t ]*([\r\n])!([^\r\n\|!]*)(?:!!|\|\|)/g, '$1|$4$2$3!');
 myContent.value = myContent.value.replace(/(\{\{College(?:Primary|Secondary)Header[^{}]*)(\}\})[\t ]*([\r\n])!([^\r\n\|!]*)[\r\n]/g, '$1|$4$2$3');
 //myContent.value = myContent.value.replace(/([^a-z]style[ ]*=[ ]*)(\{\{College(?:Primary|Secondary)[^{}]*\}\})/gi, '$1"$2"');
 myContent.value = myContent.value.replace(/<!--[ ]*GM[ ]*MARK[ ]*-->/g, '');
 myContent.value = myContent.value.replace(/(?:background(?:\-color|)[ ]*:[^;"'\{\}\|]*|text\-align[ ]*:[^;"'\{\}\|]*|color[ ]*:[^;"'\{\}\|]*)[; ]*(\{\{College(?:Primary|Secondary)[^{}]*\}\})/gi, '$1');
 
 myContent.value = myContent.value.replace(/<div class[ ]*=[" ]*NavFrame[^<>]*border\-style:none[; ]*padding:0[;" ]*>[\t ]*[\r\n]*<div[^<>]*>([^<>]*)<\/div>[\t ]*[\r\n]*<div[^<>]*>([^<>]*)<\/div><\/div>/g, '{'+'{hidden|fw1=normal|style=padding:0|$1|$2}'+'}');
 myContent.value = myContent.value.replace(/(<re)v(><\/ref>)/g, '$1f$2');
 myContent.value = myContent.value.replace(/(<span[^<>;]*);?("[ ]*>)\1;?"[ ]*>([^<>]*<\/span>)<\/span>/gi, '$1$2$3');
 myContent.value = myContent.value.replace(/[\t ]*[\r\n][\t ]*([\r\n]\|\-)/g, '$1');
 myContent.value = myContent.value.replace(/([\r\n]\|)[ ]*<div[ ]*style[ ]*=["' ]*text\-align[ ]*:[ ]*center[; '"]*>/g, '$1 style="text-align:center" | ');
 myContent.value = myContent.value.replace(/(\|\|)[ ]*<div[ ]*style[ ]*=["' ]*text\-align[ ]*:[ ]*center[; '"]*>/g, '$1 style="text-align:center" | ');
 myContent.value = myContent.value.replace(/([\r\n]\|)[ ]*<center>[ ]*/g, '$1 align=center | ');
 myContent.value = myContent.value.replace(/(\|[\t ]*(?:rowspan[ ]*=["' ]*[0-9]+["']*|colspan[ ]*=["' ]*[0-9]+["']*|width[ ]*=["' ]*[0-9pxt%]+['"]*| )+)[ ]*\|[ ]*<center>[ ]*/g, '$1 align=center | ');
 myContent.value = myContent.value.replace(/(\|\|)[ ]*<center>[ ]*/g, '$1 align=center | ');
 myContent.value = myContent.value.replace(/(\|[ ]*style[ ]*=[ ]*"[^\|\r\n"]*)("[ ]*(?:colspan[ ]*=["' ]*[0-9]+['" ]*|rowspan[ ]*=["' ]*[0-9]+['" ]*| )*\|)[ ]*<center>[ ]*/g, '$1;text-align:center;$2');
 myContent.value = myContent.value.replace(/(\|[ ]*style[ ]*=[ ]*'[^\|\r\n"]*)('[ ]*(?:colspan[ ]*=["' ]*[0-9]+['" ]*|rowspan[ ]*=["' ]*[0-9]+['" ]*| )*\|)[ ]*<center>[ ]*/g, '$1;text-align:center;$2');
 myContent.value = myContent.value.replace(/([\r\n])\|([ ]*colspan[ ]*=[" ]*[0-9]+[" ]*style[ ]*=)[ "]*(\{\{[^{}]*\}\})[; "]*(\|[ ]*)(?:<center>|<div[ ]*style[ ]*=[" ]*text\-align[ ]*:[ ]*center[;" ]*>)[ ]*(''')/gi, '$1!$2"$3;text-align:center;"$4$5');
 myContent.value = myContent.value.replace(/([\r\n])\|([ ]*colspan[ ]*=[" ]*[0-9]+[" ]*style[ ]*=)[ "]*(background[^\r\n\|]*[^\r\n; "])[; "]*(\|[ ]*)(?:<center>|<div[ ]*style[ ]*=[" ]*text\-align[ ]*:[ ]*center[;" ]*>)[ ]*(''')/gi, '$1!$2"$3;text-align:center;"$4$5');
 myContent.value = myContent.value.replace(/[\t ][\t ]+(align=center)/g, ' $1');
 myContent.value = myContent.value.replace(/([\r\n])\|[ ]*('''[^\r\n0-9]*'''[ ]*\|\|[ ]*'''[^\r\n0-9]*''')/g, '$1<!--GM CHECK-->! $2');
 myContent.value = myContent.value.replace(/(NavContent[^<>]*)text\-align[ ]*:[ ]*center[; ]*/gi, '$1');
 myContent.value = myContent.value.replace(/(<div[^<>]*")[ ]*"[ ]*(>)/g, '$1$2');
 myContent.value = myContent.value.replace(/(\|)[\t ]*[\r\n]([A-Za-z][a-zA-Z ]* score)/g, '$1 $2');
 myContent.value = myContent.value.replace(/\|(?:colspan[ ]*=[" ]*[0-9][" ]*|style[ ]*=[" ]*text\-align:center[;" ]*|[ ])*(\|)[\t ]*[\r\n]([\' ]*Legend)/g, '$1 $2');
 myContent.value = myContent.value.replace(/(\|[ ]*colspan[ ]*=[" ]*[0-9][" ]*style[ ]*=[" ]*text\-align:left)\;?([" ]*\|)[ ]*([\r\n])\{\{refbegin\}\}[\t ]*[\r\n]\*([^\r\n]*)[\r\n]\{\{refend\}\}[\t ]*[\r\n]/g, '$1;font-size:88%;$2 $4$3');
 myContent.value = myContent.value.replace(/(\|[ ]*colspan[ ]*=[" ]*[0-9][" ]*style[ ]*=[" ]*text\-align:left)\;?([" ]*\|)[ ]*([\r\n])\{\{refbegin\}\}[\t ]*[\r\n]\*([^\r\n]*)[\r\n]\*([^\r\n]*)[\r\n]\{\{refend\}\}[\t ]*[\r\n]/g, '$1;font-size:88%;$2 $4<br>$5$3');
 for(var i=1; i<3; i++) {
 myContent.value = myContent.value.replace(/([\r\n]\*)((?:[^{}\|\[\]\r\n]|\[\[[^\[\]]*\]\])*)\{\{,\}\}((?:[^{}\|\[\]\r\n]|\[\[[^\[\]]*\]\])*)([\r\n]\*[ ]*\{\{hlist)/g, '$1{'+'{hlist|1=$2|2=$3}'+'}$4');
 myContent.value = myContent.value.replace(/([\r\n])\|([^\r\n\|]*)'''([^\r\n]*)'''[\t ]*([\r\n]![^\r\n]*)<center>([^<>]*)<\/center>/g, '$1!style="text-align:left;"|$2$3$4$5');
 myContent.value = myContent.value.replace(/([\r\n]):[ ]*(\{\||\{\{Game log)/g, '$1$2');
 myContent.value = myContent.value.replace(/(\[\[[^\[\]\r\n]*)[\r\n]([^\[\]]*\{\]\])/g, '$1 $2');
 myContent.value = myContent.value.replace(/([^\|\[\]]) (\]\])/g, '$1$2 ');
 myContent.value = myContent.value.replace(/(\|\|)[\t ]*[\r\n][\t ]*(\[http)/g, '$1 $2');
 myContent.value = myContent.value.replace(/<center>[\t ]*[\r\n]*([\r\n]\{\|[^\r\n]*style[ ]*=[ ]*"[^\r\n"]*);("[\t ]*[\r\n](?:\|[^\}][^\r\n]*[\r\n]|![^\r\n]*[\r\n])*\|\})/g, '$1;margin: 0.5em auto;$2<center>');
 myContent.value = myContent.value.replace(/<center>[\t ]*[\r\n]*([\r\n]\{\|[^\r\n]*style[ ]*=[ ]*"[^\r\n"]*);("[\t ]*[\r\n](?:\|[^\}][^\r\n]*[\r\n]|![^\r\n]*[\r\n])*\|\})/g, '$1;margin: 0.5em auto;$2<center>');
 myContent.value = myContent.value.replace(/<center>[\t ]*[\r\n]*<\/center>/g, '');
 myContent.value = myContent.value.replace(/<center>[\t ]*[\r\n]*(\{\{col\-)/g, '$1');
 myContent.value = myContent.value.replace(/(\{\{col\-2[^{}]*\}\}[\t ]*[\r\n])[\t ]*[\r\n]/g, '$1');

 // myContent.value = myContent.value.replace(/(style[ ]*=[ ]*"[^\r\n<>\|"]*)"[ ]*(\|[ ]*)(?:<center>| )*<span style="([^<>\|"]*)"[ ]*>([^\r\n]*)<\/span>/g, '$1;$3"$2$4'); 
 myContent.value = myContent.value.replace(/((?:roster|staff)[ ]*==[= ]*[\r\n][\t ]*[\r\n]*[\t ]*[\r\n]*\{\|[^\r\n]*[\r\n](?:\|\-[^\r\n]*[\r\n])*)!([^\r\n]*)/gi, '$1<!--GM MARK!-->$2');
 myContent.value = myContent.value.replace(/([\r\n])!([^\r\n]*(?:staff|roster))/gi, '$1<!--GM MARK!-->$2');
 if( myContent.value.search(/record[ ]*=/gi) < 0) {
 myContent.value = myContent.value.replace(/\{\|[^\r\n]*class[="' ]*toccolours(?:collapsible|collapsed|uncollapsed| )*"[^\r\n]*[\r\n](?:\|\-[^\r\n]*[\r\n]|)(?:\|\-[^\r\n]*[\r\n]|)!(?:colspan[ ]*=[ "]*[2-9]|[" ])*style[ ]*=[" ]*([^\r\n"]*)[" ]*\|([^\r\n]*)/g, '{'+'{Game log start|style=$1|title=$2}'+'}');
 myContent.value = myContent.value.replace(/\{\|[^\r\n]*class[="' ]*toccolours(?:collapsible|collapsed|uncollapsed| )*"[^\r\n]*[\r\n](?:\|\-[^\r\n]*[\r\n]|)(?:\|\-[^\r\n]*[\r\n]|)!(?:colspan[ ]*=[ "]*[2-9]|[" ])*\|([^\r\n]*)/g, '{'+'{Game log start|style=|title=$1}'+'}');
 myContent.value = myContent.value.replace(/(\{\{Game log start)(\|[^\r\n]*\}\})[\t ]*([\r\n])(?:\|[\t ]*[\r\n]|\|\-[^\r\n]*[\r\n])*\|[\t ]*<div class="NavFrame[^<>]*>[\t ]*[\r\n][\t ]*<div class="NavContent[^<>]*>[\t ]*[\r\n]/g, '$1|title=}' + '}$3{' + '{Game log section start|hide=y$2<!--GM TOP-->$3');
 }
 myContent.value = myContent.value.replace(/<!--GM MARK!-->/g, '!');
 myContent.value = myContent.value.replace(/bgcolor[ ]*=[" ]*(#[^"\r\n{} \|]*)[" ]*(style[ ]*=[ ]*")/g, '$2background:$1;');
 myContent.value = myContent.value.replace(/(style[ ]*=[ ]*"[^"\|\r\n]*)(") bgcolor[ ]*=[" ]*(#[A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9]|gold|silver|peru)[" ]*/gi, '$1;background:$3$2');
 myContent.value = myContent.value.replace(/(style[ ]*=[ ]*"[^"\|\r\n]*)(") bgcolor[ ]*=[" ]*([A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9])[" ]*/gi, '$1;background:#$3$2');
 myContent.value = myContent.value.replace(/[\t ]*<!--[^<>]*NavFrame[^<>]*-->[\t ]*/g, '');
 myContent.value = myContent.value.replace(/(;)[ ]*color:[^;"'<>\r\n\|]*;[ ]*(color:)/g, '$1$2');
 myContent.value = myContent.value.replace(/;[ ]*font-family:calibri, serif/g, '');
 myContent.value = myContent.value.replace(/(<div[^<>]*NavHead[^<>]*>[^<>]*)<\/div>[\t ]*[\r\n]*<div[^<>]*NavHead[^<>]*>/g, '$1<br>');

 count = 0;
 lt = '';
 while(lt != myContent.value && count < 1000) {
 lt = myContent.value;
 myContent.value = myContent.value.replace(/(\{\{Adjacent stations[^{}]*[\r\n])[\t ]*[\r\n]/g, '$1');
 myContent.value = myContent.value.replace(/(\|[ ]*system)([0-9]+)([ ]*=[ ]*)TGV([\t ]*[\r\n])[\t ]*[\r\n]*(\|(?:left|right)[0-9]+)/g, '$1$2$3SNCF$4|line$2=TGV|type$2=–$5');
 myContent.value = myContent.value.replace(/(\|line[0-9]+=TGV\|type[0-9]+=–\|[^\r\n]*[\r\n])[\t ]*[\r\n]*(\|(?:left|right))([0-9]+)/g, '$1|line$3=TGV|type$3=–$2$3');
 myContent.value = myContent.value.replace(/(\|type[0-9]+=)[\-–](\|[^\r\n]*)\|to\-left[0-9]+[ ]*=([^\r\n\|]*)\|to\-right[0-9]+[ ]*=([^\r\n\|]*)/g, '$1$3–$4$2');
 
 myContent.value = myContent.value.replace(/(\{\{cite[^{}\r\n]*)[\t ][\t ]+([^{}]*\}\})/g, '$1 $2');
 myContent.value = myContent.value.replace(/([\r\n]\|\-[^\r\n]*)(style[ ]*=[ ]*"[^\r\n"]*")([^\r\n]*[\r\n]<!--GM CHECK-->!)/g, '$1$3 $2 |');
 myContent.value = myContent.value.replace(/(<!--GM CHECK-->)(![ ]*)(style[ ]*=[ ]*"[^\r\n"]*")([ ]*\|[^\[\]\|\r\n]*)\|\|/g, '$2$3$4\n$1! $3 |');
 var ltt = '';
 while(ltt != myContent.value && count < 1000) {
 ltt = myContent.value;
 myContent.value = myContent.value.replace(/(\{\{cite[^{}\r\n]*)(<!--GM KBR TABLE-->)[\t ]*[\r\n]([^{}\r\n]*)/gi, '$1 $3$2');
 myContent.value = myContent.value.replace(/(<!--GM KBR TABLE-->)(\}\}[^\r\n]*)/g, '$2$1');
 myContent.value = myContent.value.replace(/(\{\{cite[^{}\r\n]*)[\t ][\t ]+([^{}]*\}\})/g, '$1 $2');
 count++;
 }
 myContent.value = myContent.value.replace(/(<!--GM KBR TABLE-->[\t ]*[\r\n]\|)[\t ]*(\{\{flag)/gi, '$1 style="text-align:left" | $2');
 myContent.value = myContent.value.replace(/(<!--GM KBR TABLE-->[\t ]*[\r\n]\|[^\r\n]*\|\|)[\t ]*(\{\{flag)/gi, '$1 style="text-align:left" | $2');
 myContent.value = myContent.value.replace(/(<!--GM KBR TABLE-->)[\t ]*[\r\n][\t ]*(\|\|[^\r\n]*)/g, ' $2$1');
 myContent.value = myContent.value.replace(/(<!--GM KBR TABLE-->[\t ]*[\r\n])[\t ]*(\|\-)/gi, '$1$2');
 myContent.value = myContent.value.replace(/(<!--GM KBR TABLE-->[\t ]*[\r\n]\|\-[^\r\n]*)[ ]*align[ ]*=['" ]*center['" ]*/g, '$1 ');
 myContent.value = myContent.value.replace(/(<!--GM KBR TABLE-->[\t ]*[\r\n]\|\-[^\r\n]*)text\-align[ ]*:[ ]*center[; ]*/g, '$1');
 myContent.value = myContent.value.replace(/(<!--GM KBR TABLE-->[\t ]*[\r\n]\|)[\t ]*(\{\{flag)/gi, '$1 style="text-align:left" | $2');
 myContent.value = myContent.value.replace(/(<!--GM KBR TABLE-->[\t ]*[\r\n]\|[^\r\n]*\|\|)[\t ]*(\{\{flag)/gi, '$1 style="text-align:left" | $2');
 myContent.value = myContent.value.replace(/(<!--GM KBR TABLE-->)[\t ]*([\r\n]\|[^\}][^\r\n]*)([\r\n])/g, '$2$1$3');
 myContent.value = myContent.value.replace(/(<!--GM KBR TABLE-->)[\t ]*([\r\n]![^\r\n]*colspan[^\r\n]*)([\r\n])/g, '$2$1$3');
 myContent.value = myContent.value.replace(/(<!--GM KBR TABLE-->)[\r\n](\}\}<\/ref>[^\r\n]*)([\r\n])/g, '$2$1$3');
 myContent.value = myContent.value.replace(/<!--GM KBR TABLE-->[\t ]*[\r\n]?[\t ]*([\r\n])\|\}[\t ]*[\r\n]*[\t ]*[\r\n]*\|\}/g, '$1{'+'{end}'+'}');
 myContent.value = myContent.value.replace(/<!--GM KBR TABLE-->[\t ]*[\r\n]?[\t ]*([\r\n])\|\}[\t \r\n]*[\r\n]/g, '$1|-$1| colspan=9 | <!--GM KBR FOOT-->');
 myContent.value = myContent.value.replace(/<!--GM KBR TABLE-->([\r\n]\{\{end\}\})/g, '$1');
 myContent.value = myContent.value.replace(/(<!--GM KBR FOOT-->)()[\r\n]([^\|=\r\n][^\r\n]*)/g, '$2 $3$1');
 myContent.value = myContent.value.replace(/(<!--GM KBR FOOT-->)([^=\r\n][^\r\n]*)[\r\n]([^\|][^\r\n]*)/g, '$2 $3$1');
 myContent.value = myContent.value.replace(/<!--GM KBR FOOT-->((?:[^=\r\n][^\r\n]*|)[\r\n])\|\}/g, '$1{'+'{end}'+'}');
 myContent.value = myContent.value.replace(/\| colspan=9 \|[\t ]*<!--GM KBR FOOT-->\|\}[\t ]*([\r\n])/g, '{'+'{end}'+'}$1');
 // myContent.value = myContent.value.replace(/([\r\n])(![^\r\n]*)!(![ ]*style[ ]*=)/g, '$1$2$1$3');
 myContent.value = myContent.value.replace(/(<!--GM HIDDEN-->)((?:[\r\n]|[^<>]|<br[^<>]*>|<ref[^<>]*>|<\/ref>)*)/gi, '$2$1');
 myContent.value = myContent.value.replace(/(<!--GM HIDDEN-->)<\/div>[\t \r\n]*<\/div>/gi, '{'+'{collapse bottom}'+'}');
 myContent.value = myContent.value.replace(/(<!--[^<>]*Ogre[^<>]*-->)[\t ]*[\r\n]*<!--[^<>]*Ogre[^<>]*-->/g, '$1');
 myContent.value = myContent.value.replace(/[\r\n][\t ]*(<\/div>)/g, '$1');
 myContent.value = myContent.value.replace(/(\{\{Game log start[^\r\n]*[\r\n]![^\r\n\|]*)colspan[ ]*=[" ]*2[" ]*((?:\{\{[^{}]*\}\}|[^\r\n\|\{\}])*\|[ ]*(?:Regular Season)[^\r\n]*[\r\n](?:\|\-[^\r\n]*[\r\n]|))\{\{Game log section end\}\}[\t ]*[\r\n]/gi, '$1$2');
 myContent.value = myContent.value.replace(/(\{\{Game log start[^\r\n]*[\r\n])(\{\{Game log section end\}\}|\|\-[^\r\n]*)[\r\n]/g, '$1');
 if( myContent.value.search(/record[ ]*=/gi) < 0) {
 myContent.value = myContent.value.replace(/\|[ ]*colspan[ ]*=[" ]*[0-9]+[" ]*\|[ ]*[\r\n]\{\|[ ]*class[ ]*=[ ]*"[^"]*collapsible collapsed[^\r\n]*[\r\n](?:\|\-[^\r\n]*[\r\n]|)![ ]*colspan[ ]*=[ "]*[0-9]+[" ]*style[ ]*=[ ]*"((?:[^"\r\n\|]|\{\{[^{}]*\}\})*)"\|([^\r\n]*)/gi, '{'+'{Game log section end}'+'}\n{'+'{Game log section start|hide=y|style=$1|title=$2}'+'}<!--GM TOP-->');
 }
 myContent.value = myContent.value.replace(/(<div [^<>]*style[ ]*=[ ]*"[^<>"]*;)("[^<>]*>)<span[ ]*style[ ]*=[ ]*"([^<>"]*)"[ ]*>((?:<small>|<\/small>|[^<>])*)<\/span>/gi, '$1$3$2$4');
 myContent.value = myContent.value.replace(/(<div [^<>]*style[ ]*=[ ]*"[^<>"]*)("[^<>]*>)<span[ ]*style[ ]*=[ ]*"([^<>"]*)"[ ]*>((?:<small>|<\/small>|[^<>])*)<\/span>/gi, '$1;$3$2$4');
 if( myContent.value.search(/record[ ]*=/gi) < 0) {
 myContent.value = myContent.value.replace(/\|[ \r\n]*<div class="NavFrame[^<>]*>(?:<!--[^<>]*-->|[\t \r\n])*<div class="NavHead"[ ]*style[ ]*=[ ]*"?([^<>"]*)"?[ ]*>((?:<span[^<>]*>|<\/span>|<br[^<>]*>|<\/*small>|<ref[^<>]*>|<\/ref>|<!--[^<>]*-->|[^<>])*)<\/div>[\t \r\n]*<div(?: style[^<>]*|) class="NavContent"[^<>]*>/gi, '{'+'{Game log section end}'+'}\n{'+'{Game log section start|hide=y|style=$1|title=$2}'+'}<!--GM TOP-->');
 myContent.value = myContent.value.replace(/\|[ \r\n]*<div class="NavFrame[^<>]*>(?:<!--[^<>]*-->|[\t \r\n])*<div class="NavHead"[ ]*style[ ]*=[ ]*"?([^<>"]*)"?[ ]*>((?:<span[^<>]*>|<\/span>|<br[^<>]*>|<ref[^<>]*>|<\/*small>|<\/ref>|<!--[^<>]*-->|[^<>])*)<\/div>[\t \r\n]*<div(?: style[^<>]*|) class="NavContent"[^<>]*>/gi, '{'+'{Game log section end}'+'}\n{'+'{Game log section start|hide=y|style=$1|title=$2}'+'}<!--GM TOP-->');
 myContent.value = myContent.value.replace(/\|[ \r\n]*[\r\n]\{\|[ ]*class[ ]*=[" ]*wikitable collapsible[^\r\n]*[\r\n](?:\|\-[^\r\n]*[\r\n]|)![ ]*colspan[ ]*=[" ]*1[0-9][" ]*style[ ]*=[ "]*padding\-left[ ]*:[ ]*[0-9]*em[; ]*((?:\{\{[^{}]*\}\}|[^"\|])*)[" ]*\|([^\r\n]*)/gi, '{'+'{Game log section end}'+'}\n{'+'{Game log section start|hide=y|style=$1|title=$2}'+'}<!--GM TOP-->');
 }
 myContent.value = myContent.value.replace(/(\}\}<!--GM TOP-->)[\t ]*[\r\n]\{\{center\|[ ]*'''([^{}]*)'''[ ]*\}\}/g, '<br>$2$1');
 myContent.value = myContent.value.replace(/<!--GM (?:TOP|HEADINGS)--><!--GM (?:TOP|HEADINGS)-->/g, '<!--GM HEADINGS-->');
 myContent.value = myContent.value.replace(/(<!--GM TOP-->)[\t ]*[\r\n]*[\r\n](?:<center>|<div[\t ]*style[\t ]*=[\t "]*text\-align[\t ]*:[\t ]*center[;\t "]*>)/g, '$1');
 myContent.value = myContent.value.replace(/(<!--GM TOP-->)[\t ]*[\r\n]*[\r\n]\{\|[^\r\n]*/g, '$1');
 myContent.value = myContent.value.replace(/(<!--GM TOP-->)[\t ]*[\r\n]*[\r\n][\t ]*\|\-[^\r\n]*/g, '$1');
 myContent.value = myContent.value.replace(/(<!--GM (?:TOP|HEADINGS)-->[\t ]*[\r\n])[\t ]*[\r\n]/g, '$1');
 myContent.value = myContent.value.replace(/((?:<!--GM TOP-->|<!--GM HEADINGS-->)[\t ]*[\r\n]*[\t ]*)(<!--[^G<>][^<>]*-->)/g, '$2$1');
 myContent.value = myContent.value.replace(/\}\}<!--GM (?:TOP|HEADINGS)-->[\t ]*[\r\n]*[\r\n]![ ]*(?:[^\|\r\n\[\]\{\}=]|style[ ]*=|bgcolor[ ]*=|width[ ]*=|\{\{[^{}]*\}\})*\|((?:\[\[[^\[\]\r\n]*\]\]|\{\{[^{}]*\}\}|[^\r\n!\|\[\]\{\}]|<ref[^<>\/]*>[^<>]*<\/ref>)*)[\r\n]/g, '|$1}}<!--GM HEADINGS-->\n');
 myContent.value = myContent.value.replace(/\}\}<!--GM (?:TOP|HEADINGS)-->[\t ]*[\r\n]*[\r\n]![ ]*colspan[ ]*=["' ]*2["' ]*(?:[^\|\r\n\[\]\{\}=]|style[ ]*=|\{\{[^{}]*\}\})*\|((?:\[\[[^\[\]\r\n]*\]\]|\{\{[^{}]*\}\}|[^\r\n!\|\[\]\{\}]|<ref[^<>\/]*>[^<>]*<\/ref>)*)[\r\n]/g, '|<!--GM COLSPAN-->colspan=2|$1}}<!--GM HEADINGS-->\n');
 myContent.value = myContent.value.replace(/\}\}<!--GM (?:TOP|HEADINGS)-->[\t ]*[\r\n]*[\r\n]![ ]*(?:[^\|\r\n\[\]\{\}=]|style[ ]*=|\{\{[^{}]*\}\})*[\t ]*class[ ]*=[" ]*unsortable[" ]*\|((?:\[\[[^\[\]\r\n]*\]\]|\{\{[^{}]*\}\}|[^\r\n!\|\[\]\{\}]|<ref[^<>\/]*>[^<>]*<\/ref>)*)[\r\n]/g, '|<!--GM CLASS-->class=unsortable|$1}}<!--GM HEADINGS-->\n');
 myContent.value = myContent.value.replace(/\}\}<!--GM (?:TOP|HEADINGS)-->[\t ]*[\r\n]*[\r\n]![ ]((?:\[\[[^\[\]\r\n]*\]\]|\{\{[^{}]*\}\}|[^\r\n!\|\{\}]|<ref[^<>\/]*>[^<>]*<\/ref>)*)\|\|/g, '|$1}}<!--GM HEADINGS-->\n!');
 myContent.value = myContent.value.replace(/\}\}<!--GM (?:TOP|HEADINGS)-->[\t ]*[\r\n]*[\r\n]![ ]((?:\[\[[^\[\]\r\n]*\]\]|\{\{[^{}]*\}\}|[^\r\n!\|\{\}]|<ref[^<>\/]*>[^<>]*<\/ref>)*)!!/g, '|$1}}<!--GM HEADINGS-->\n!');
 myContent.value = myContent.value.replace(/\}\}<!--GM (?:TOP|HEADINGS)-->[\t ]*[\r\n]*[\r\n]![ ]((?:\[\[[^\[\]\r\n]*\]\]|\{\{[^{}]*\}\}|[^\r\n!\|\{\}]|<ref[^<>\/]*>[^<>]*<\/ref>)*)([\r\n])/g, '|$1}}<!--GM HEADINGS-->$2');
 myContent.value = myContent.value.replace(/<!--GM HEADINGS-->[\t ]*[\r\n]*([\r\n])[\t ]*(\|\-)/g, '$1$2');
 myContent.value = myContent.value.replace(/<!--GM HEADINGS-->[\t ]*([\r\n][\t ]*(?:\|\}|\{\{Game log section end\}\}))/g, '$1');
 myContent.value = myContent.value.replace(/[\r\n]\|\}(?:<\/div>|<\/center>|[\t ])*[\r\n]\|\-[^\r\n]*([\r\n]\{\{Game log section end)/g, '$1');
 count++;
 }
 count = 0;

 lt = '';
 myContent.value = myContent.value.replace(/<!--GM CHECK-->/g, '');
 myContent.value = myContent.value.replace(/(\{\|[^\r\n]*[\r\n](?:\|\-[^\r\n]*[\r\n]|)![ ]*colspan[ ]*=[" ]*2[" ]*\|[ ']*)(Legend)/g, '$1<!--' + 'GM MARK-->$2');
 while(lt != myContent.value && count < 1000) {
 lt = myContent.value;
 
 myContent.value = myContent.value.replace(/(![ ]*colspan[ ]*=[" ]*2[" ]*\|[ ']*Legend[^\r\n]*[\r\n]\|\-[\t ]*[\r\n])(\|\-[^\r\n]*[\r\n])/g, '$2$1');
 myContent.value = myContent.value.replace(/(![ ]*colspan[ ]*=[" ]*2[" ]*\|[ ']*Legend[^\r\n]*[\r\n]\|\-[\t ]*[\r\n])((?:![^\r\n]*[\r\n]|\|[^\}\r\n][^\r\n]*[\r\n]|\|[\r\n]))/g, '$2$1');
 myContent.value = myContent.value.replace(/(![ ]*colspan[ ]*=[" ]*2[" ]*\|[ ']*Legend[^\r\n]*[\r\n]\|\-[\t ]*[\r\n])(\{\{Game log section[^\r\n]*[\r\n])/g, '$2$1');
 myContent.value = myContent.value.replace(/(![ ]*colspan[ ]*=[" ]*2[" ]*\|[ ']*Legend[^\r\n]*[\r\n]\|\-[\t ]*[\r\n])(\|\}[\t ]*[\r\n]\|[^\r\n]*[\r\n])/g, '$2$1');
 count++;
 }
 myContent.value = myContent.value.replace(/<!--[ ]*GM[ ]+MARK[ ]*-->/g, '');
 count = 0;
 lt = '';
 while(lt != myContent.value && count < 1000) {
 lt = myContent.value;
 myContent.value = myContent.value.replace(/([\r\n]![^\r\n]*all games (?:are viewable|live)[^\r\n]*)([\r\n](?:\||!|<div|<\/div>|\{\||\{\{Game log section)[^\r\n]*)/gi, '$2$1');
 count++;
 }
 myContent.value = myContent.value.replace(/([\r\n]\{\{Game log end[^\r\n]*)([\r\n]![^\r\n]*all games (?:are viewable|live)[^\r\n]*)/gi, '$2$1');
 myContent.value = myContent.value.replace(/Watch all games live on([^\r\n]*)/g, 'All games are viewable on$1');
 myContent.value = myContent.value.replace(/\'\'[\t ]*(All games are viewable[^\r\n]*)\'\'/g, '$1');
 myContent.value = myContent.value.replace(/(\{\{College(?:Primary|Secondary)Header\|team=[^{}\|]*\|[^{}\|]*\|[^{}\|]*\|)<!--GM CLASS-->(class)[ ]*/g, '$1$23');
 myContent.value = myContent.value.replace(/(\{\{College(?:Primary|Secondary)Header\|team=[^{}\|]*\|[^{}\|]*\|[^{}\|]*\|[^{}\|]*\|)<!--GM CLASS-->(class)[ ]*/g, '$1$24');
 lt = '';
 count = 0;
 myContent.value = myContent.value.replace(/<!--GM (?:TOP|FOOT)-->/g, '');
 myContent.value = myContent.value.replace(/(\{\{Game log section start[^\r\n]*)/g, '$1<!--GM TOP-->');
 myContent.value = myContent.value.replace(/(\{\{Game log section end[^{}]*\}\})/g, '$1<!--GM FOOT-->');
 while(lt != myContent.value && count < 1000) {
 lt = myContent.value;
 myContent.value = myContent.value.replace(/(<!--GM TOP-->)[\t ]*([\r\n])[\t ]*(\|[^\}\r\n][^\r\n]*)/g, '$2$3$1');
 myContent.value = myContent.value.replace(/(<!--GM TOP-->)[\t ]*([\r\n])[\t ]*(\|)([\r\n])/g, '$2$3$1$4');
 myContent.value = myContent.value.replace(/<!--GM TOP-->[\t ]*([\r\n])!([^\r\n']*[0-9][0-9][0-9][0-9][^\r\n']*)([\r\n])/g, ' style="background:#f2f2f2; font-weight:bold;"$1| $2<!--GM BOLD ROW-->$3');
 myContent.value = myContent.value.replace(/(<!--GM BOLD ROW-->[\t ]*[\r\n]\|[^\r\n]*)\'\'\'/g, '$1');
 myContent.value = myContent.value.replace(/(<!--GM BOLD ROW-->[\t ]*[\r\n]\|[^\r\n]*)\'\'\'/g, '$1');
 myContent.value = myContent.value.replace(/(<!--GM BOLD ROW-->)[\t ]*([\r\n])!((?:[^\r\n']|[^\'\r\n]\'[^\'\r\n])*)([\r\n])/g, '$2| $3$1$4');
 myContent.value = myContent.value.replace(/(<!--GM BOLD ROW-->)[\t ]*([\r\n]\|[^\-\}](?:[^\r\n']|[^\'\r\n]\'[^\'\r\n])*)([\r\n])/g, '$2$1$3');
 myContent.value = myContent.value.replace(/(<!--GM BOLD ROW-->)[\t ]*([\r\n]\|)([\r\n])/g, '$2$1$3');
 myContent.value = myContent.value.replace(/<!--GM BOLD ROW-->[\t ]*([\r\n](?:\|\-|\|\}|\{\{))/g, '<!--GM TOP-->$1');
 myContent.value = myContent.value.replace(/<!--GM TOP-->[\t ]*([\r\n])\|\}(?:[\t ]|<\/div>|<\/center>)*/g, '$1{'+'{Game log section end}'+'}');
 myContent.value = myContent.value.replace(/<!--GM TOP-->[\t ]*([\r\n]\{\{Game log section end)/g, '$1');
 myContent.value = myContent.value.replace(/<!--GM FOOT-->([\t ]*[\r\n])(?:\|\-[^\r\n]*[\r\n]|[\t ]|[\r\n])*\|\}/g, '$1{'+'{Game log end}'+'}');
 myContent.value = myContent.value.replace(/(<!--GM FOOT-->)[\t ]*([\r\n]\|\-[^\r\n]*)/g, '$2$1');
 myContent.value = myContent.value.replace(/<!--GM FOOT-->[\t ]*([\r\n]!)[ ]*colspan[ ]*=[" ]*2[" ]*(style[^\r\n]*\|[^\r\n]*[\r\n](?:\|\-[^\r\n]*[\r\n]|[\t ])*)\{\{Game log section end\}\}[\t ]*[\r\n]/gi, '$1 $2');
 // myContent.value = myContent.value.replace(/(<!--GM FOOT-->)[\t ]*([\r\n])!(?:colspan[ ]*=[^\|]*|style[ ]*=[^\|]*|[\t ])*\|[ ]*([^\r\n]*)([\r\n])/g, '$2| $3$1$4');
 myContent.value = myContent.value.replace(/(<!--GM FOOT-->)[\t ]*([\r\n]![\t ]*style[ ]*=[ ]*[^\r\n=]*\|[^\r\n]*)/gi, '$2$1');
 myContent.value = myContent.value.replace(/(<!--GM FOOT-->)[\t ]*([\r\n])![ ]*([^\r\n\|]*)([\r\n])/g, '$2| $3$1$4');
 myContent.value = myContent.value.replace(/(<!--GM FOOT-->)[\t ]*([\r\n]\|[^\}][^\r\n]*)/g, '$2$1');
 myContent.value = myContent.value.replace(/(<!--GM FOOT-->)[\t ]*([\r\n])[\t ]*(<ref[^\r\n]*)/g, '$2|-$2| $3$1');
 myContent.value = myContent.value.replace(/(<!--GM FOOT-->)[\t ]*([\r\n]\{\{[Ll]egend[^{}]*\}\}[^\r\n]*)/g, '$2$1');
 myContent.value = myContent.value.replace(/<!--GM FOOT-->[\t ]*([\r\n]\{\{Game log (?:section start|end))/g, '$1');
 myContent.value = myContent.value.replace(/([\r\n]\|[^\-\}][^\r\n]*)([\r\n]\{\{Game log section end)/g, '$1\n|-$2');
 myContent.value = myContent.value.replace(/(<!--GM FOOT-->)[\t ]*[\r\n][\t ]*[\r\n]*<small>([^\r\n]*)<\/small>(?:<br[^<>]*>|[\t ])*([\r\n])/g, '$3|-$3| style="font-size:88%" | $2$1$3');
 myContent.value = myContent.value.replace(/<!--GM FOOT-->([\t ]*[\r\n](?:\|\-[^\r\n]*[\r\n]|))![ ]*colspan[ ]*=["' ]*[0-9]+["' ]*(?:style[ ]*=[^\|]*|)(\|[^\r\n]*[\r\n](?:\|\-[^\r\n]*[\r\n]|))\|\}/g, '$1$2{'+'{Game log end}'+'}');
 myContent.value = myContent.value.replace(/\{\{Game log section end}}[\t ]*[\r\n](?:\|\-[^\r\n]*[\r\n]|[\t ]*[\r\n]|<!--GM FOOT-->)*(\{\{Game log section end\}\})/g, '$1');
 myContent.value = myContent.value.replace(/(\{\{Game log(?:\{\{[^{}]*\}\}|[^{}])*)'''/gi, '$1');
 myContent.value = myContent.value.replace(/(\{\{Game log[^{}]*\|[ ]*style[ ]*=(?:\{\{[^{}]*\}\}|[^\|\{\}])*)(\|title[ ]*=[ ]*)<span[ ]*style[ ]*=[" ]*([^<>"]*)[" ]*>((?:<span[^<>]*>[^<>]*<\/span>|<br[^<>]*>|[^\{\}<>])*)<\/span>/g, '$1;$3$2$4');
 myContent.value = myContent.value.replace(/(style[ ]*=[^\|\{\}<>\r\n]*;)[ ]*;/g, '$1');
 myContent.value = myContent.value.replace(/([\r\n])\{\|[^\r\n]*[\r\n](?:\|\-[^\r\n]*[\r\n]|)(\{\{Game log) section end(\}\})/g, '$1$2 start|title=$3');
 myContent.value = myContent.value.replace(/(\{\{Game log[^{}]*)text\-align[ ]*:[ ]*center[; ]*/gi, '$1');
 myContent.value = myContent.value.replace(/(\{\{Game log end\}\})[\t ]*[\r\n]*[\t ]*[\r\n]*[\t ]*[\r\n]*(<ref[^\r\n]*)/g, '|-\n| $2\n$1');
 myContent.value = myContent.value.replace(/(\{\{Game log end\}\})[\t ]*[\r\n]*[\t ]*[\r\n]*[\t ]*[\r\n]*<small>([^\r\n]*)<\/small>/g, '|-\n| style="font-size:88%"| $2\n$1');
 myContent.value = myContent.value.replace(/(\{\{College(?:Primary|Secondary)Header(?:\{\{[^{}]*\}\}|[^{}])*)'''/g, '$1');
 count++;
 }
 // myContent.value = myContent.value.replace(/^\|[ ]*'''([^\|\r\n!\'])*'''[ ]*\|\|/g, '! $2 !!');
 if (myContent.value.search(/<[\t ]*center/gi) < 0) {
 myContent.value = myContent.value.replace(/<\/center>/gi, '');
 }
 if (myContent.value.search(/<[\t ]*span/gi) < 0) {
 myContent.value = myContent.value.replace(/<\/span>/gi, '');
 }
 if (myContent.value.search(/<[\t ]*div/gi) < 0) {
 myContent.value = myContent.value.replace(/<\/div>/gi, '');
 }
 }
 }
 myContent.value = myContent.value.replace(/(\[\[[Cc]ategory:[^\[\]{}\|]*)\|\{\{PAGENAME\}\}(\]\])/g, '$1$2');
 myContent.value = myContent.value.replace(/(\[\[[Cc]ategory:Non-talk pages that are automatically signed)(\]\])/g, '$1|{'+'{PAGENAME}'+'}$2');
 lt = '';
 count = 0;
 if (mw.config.get('wgNamespaceNumber') == 0) {
 if (myContent.value.search(/<!--GM/g) >= 0) {
 alert('Half converted content!');
 }
 if (myContent.value.search(/NavContent/g) >= 0) {
 alert('NavContent!');
 }
 if (myContent.value.search(/<[\/]*div/gi) >= 0) {
 alert('Div!');
 }
 if (myContent.value.search(/<[\/]*center/gi) >= 0) {
 alert('Center!');
 }
 if( (myContent.value.match(/\{\{Game log start/g) || []).length != (myContent.value.match(/\{\{Game log end/g) || []).length) {
 alert('Number of log start != Number of log end');
 }
 if( (myContent.value.match(/\{\{Game log section start/g) || []).length != (myContent.value.match(/\{\{Game log section end/g) || []).length) {
 alert('Number of log section start != Number of log section end');
 }
 
 myContent.value = myContent.value.replace(/(\{\{nowrap) begin\}\}((?:[^\r\n\[\]\{\}\|=]|\[\[[^\[\]]*\]\]|\{\{[^{}]*\}\})*?)\{\{nowrap end(\}\})/g, '$1|$2$3');
 myContent.value = myContent.value.replace(/(\{\{nowrap\|(?:[^\r\n\[\]\{\}\|=]|\[\[[^\[\]]*\]\]|\{\{[^{}]*\}\})*)\{\{nowrap end\}\}([\t ]*)\{\{nowrap begin\}\}/g, '$1}' + '}$2{' + '{nowrap|');
 }
 
 myContent.value = myContent.value.replace(/(\|[ ]*header1[ ]*=[^\r\n]*[\r\n])\|[ ]*label1[ ]*=([^\r\n]*[\r\n])\|[ ]*data1[ ]*=([^\r\n]*[\r\n])(\|[ ]*label2[ ]*=)\2(\|[ ]*data2[ ]*=)\3/gi, '$1$4$2$5$3');
 myContent.value = myContent.value.replace(/(\|[ ]*lat[0-9]*_deg[ ]*=[ ]*)(0[\.0]*[ ]*\|[ ]*lat[0-9]*_min[ ]*=[ ]*\-)/g, '$1-$2');
 myContent.value = myContent.value.replace(/(\|[ ]*lon[0-9]*_deg[ ]*=[ ]*)(0[\.0]*[ ]*\|[ ]*lon[0-9]*_min[ ]*=[ ]*\-)/g, '$1-$2');
 myContent.value = myContent.value.replace(/(\|[ ]*lat[0-9]*_deg[ ]*=[ ]*\-[0-9\.]+[ ]*\|[ ]*lat[0-9]*_min[ ]*=[ ]*)(0[0\.]*[\r\n ]*\|)/g, '$1-$2');
 myContent.value = myContent.value.replace(/(\|[ ]*lon[0-9]*_deg[ ]*=[ ]*\-[0-9\.]+[ ]*\|[ ]*lon[0-9]*_min[ ]*=[ ]*)(0[0\.]*[\r\n ]*\|)/g, '$1-$2');
 myContent.value = myContent.value.replace(/\|[ ]*lat([0-9]*)_deg[ ]*=[ ]*\-([0-9\.]+)[ ]*\|[ ]*lat\1_min[ ]*=[ ]*\-([0-9\.]+)[\r\n ]*\|[ ]*lon\1_deg[ ]*=[ ]*([0-9\.]+)[ ]*\|[ ]*lon\1_min[ ]*=[ ]*([0-9\.]+)[ ]*/g, '|coordinates$1={' + '{coord|$2|$3|S|$4|$5|E}}');
 myContent.value = myContent.value.replace(/\|[ ]*lat([0-9]*)_deg[ ]*=[ ]*\-([0-9\.]+)[ ]*\|[ ]*lat\1_min[ ]*=[ ]*\-([0-9\.]+)[ ]*\|[ ]*lat\1_sec[ ]*=[ ]*\-([0-9\.]+)[\r\n ]*\|[ ]*lon\1_deg[ ]*=[ ]*([0-9\.]+)[ ]*\|[ ]*lon\1_min[ ]*=[ ]*([0-9\.]+)[ ]*\|[ ]*lon\1_sec[ ]*=[ ]*([0-9\.]+)[ ]*/g, '|coordinates$1={' + '{coord|$2|$3|$4|S|$5|$6|$7|E}}');
 myContent.value = myContent.value.replace(/\|[ ]*lat([0-9]*)_deg[ ]*=[ ]*([0-9\.]+)[ ]*\|[ ]*lat\1_min[ ]*=[ ]*([0-9\.]+)[\r\n ]*\|[ ]*lon\1_deg[ ]*=[ ]*\-([0-9\.]+)[ ]*\|[ ]*lon\1_min[ ]*=[ ]*\-([0-9\.]+)[ ]*/g, '|coordinates$1={' + '{coord|$2|$3|N|$4|$5|W}}');
 myContent.value = myContent.value.replace(/\|[ ]*lat([0-9]*)_deg[ ]*=[ ]*([0-9\.]+)[ ]*\|[ ]*lat\1_min[ ]*=[ ]*([0-9\.]+)[ ]*\|[ ]*lat\1_sec[ ]*=[ ]*([0-9\.]+)[\r\n ]*\|[ ]*lon\1_deg[ ]*=[ ]*\-([0-9\.]+)[ ]*\|[ ]*lon\1_min[ ]*=[ ]*\-([0-9\.]+)[ ]*\|[ ]*lon\1_sec[ ]*=[ ]*\-([0-9\.]+)[ ]*/g, '|coordinates$1={' + '{coord|$2|$3|$4|N|$5|$6|$7|W}}');
 myContent.value = myContent.value.replace(/\|[ ]*lat([0-9]*)_deg[ ]*=[ ]*\-([0-9\.]+)[ ]*\|[ ]*lat\1_min[ ]*=[ ]*\-([0-9\.]+)[\r\n ]*\|[ ]*lon\1_deg[ ]*=[ ]*\-([0-9\.]+)[ ]*\|[ ]*lon\1_min[ ]*=[ ]*\-([0-9\.]+)[ ]*/g, '|coordinates$1={' + '{coord|$2|$3|S|$4|$5|W}}');
 myContent.value = myContent.value.replace(/\|[ ]*lat([0-9]*)_deg[ ]*=[ ]*\-([0-9\.]+)[ ]*\|[ ]*lat\1_min[ ]*=[ ]*\-([0-9\.]+)[ ]*\|[ ]*lat\1_sec[ ]*=[ ]*\-([0-9\.]+)[\r\n ]*\|[ ]*lon\1_deg[ ]*=[ ]*\-([0-9\.]+)[ ]*\|[ ]*lon\1_min[ ]*=[ ]*\-([0-9\.]+)[ ]*\|[ ]*lon\1_sec[ ]*=[ ]*\-([0-9\.]+)[ ]*/g, '|coordinates$1={' + '{coord|$2|$3|$4|S|$5|$6|$7|W}}');
 if(myContent.value.search(/\{\{[_ ]*location map[^{}]*\{\{coord/gi) >= 0) {
 myContent.value = myContent.value.replace(/\|[ ]*lat([0-9]*)_deg[ ]*=[ ]*([0-9\.]+)[ ]*\|[ ]*lat\1_min[ ]*=[ ]*([0-9\.]+)[\r\n ]*\|[ ]*lon\1_deg[ ]*=[ ]*([0-9\.]+)[ ]*\|[ ]*lon\1_min[ ]*=[ ]*([0-9\.]+)[ ]*/g, '|coordinates$1={' + '{coord|$2|$3|N|$4|$5|E}}');
 myContent.value = myContent.value.replace(/\|[ ]*lat([0-9]*)_deg[ ]*=[ ]*([0-9\.]+)[ ]*\|[ ]*lat\1_min[ ]*=[ ]*([0-9\.]+)[ ]*\|[ ]*lat\1_sec[ ]*=[ ]*([0-9\.]+)[\r\n ]*\|[ ]*lon\1_deg[ ]*=[ ]*([0-9\.]+)[ ]*\|[ ]*lon\1_min[ ]*=[ ]*([0-9\.]+)[ ]*\|[ ]*lon\1_sec[ ]*=[ ]*([0-9\.]+)[ ]*/g, '|coordinates$1={' + '{coord|$2|$3|$4|S|$5|$6|$7|E}}');
 myContent.value = myContent.value.replace(/\|[ ]*lat(?:_deg|)[ ]*=[ ]*(\-?[0-9\.]+)[\r\n ]*\|[ ]*lon(?:_de|)g[ ]*=[ ]*(\-?[0-9\.]+)[ ]*/g, '|coordinates={' + '{coord|$1|$2}}');
 myContent.value = myContent.value.replace(/\|[ ]*lat([0-9]+)(?:_deg|)[ ]*=[ ]*(\-?[0-9\.]+)[\r\n ]*\|[ ]*(?:lon\1_deg|long\1)[ ]*=[ ]*(\-?[0-9\.]+)[ ]*/g, '|coordinates$1={' + '{coord|$2|$3}}');
 }
 
 while(lt != myContent.value && count < 1000) {
 lt = myContent.value;
 count = count + 1;

 if(myContent.value.search(/NBA color cell/gi) >=0 ) {
 myContent.value = myContent.value.replace(/(\{\{)[Nn]avbox/g, '$1Team roster navbox');
 myContent.value = myContent.value.replace(/(\{\{Team roster navbox)[_ ]*\|[_ ]*(child|subgroup)/g, '$1|border=$2');
 }
 if(myContent.value.search(/\{\{[Rr]h[mw]/gi) >= 0 ) {
 myContent.value = myContent.value.replace(/\|matches_style=FBR/g, '|team_header=Team|short_style=noflag');
 }
 myContent.value = myContent.value.replace(/<!--FB LINK: ([^<>]*)-->(\{\{[Rr]h[mw]\|)\1/g, '$2$1');

 myContent.value = myContent.value.replace(/(\|[ ]*coordinates[ ]*=[ ]*)([0-9]+)°[\t ]*([0-9]+)[\t ]*[′'][\t ]*([0-9\.]+)[\t ]*["″][\t ]*([NS])[\t,; ]*([0-9]+)°[\t ]*([0-9]+)[\t ]*[′'][\t ]*([0-9\.]+)[\t ]*["″][\t ]*([EW])/gi, '$1{'+'{coord|$2|$3|$4|$5|$6|$7|$8|$9}'+'}');
 myContent.value = myContent.value.replace(/(\|[ ]*coordinates[ ]*=[ ]*)([0-9]+)°[\t ]*([0-9]+)[\t ]*[′'][\t ]*([0-9\.]+)[\t ]*["″][\t ]*([EW])[\t,; ]*([0-9]+)°[\t ]*([0-9]+)[\t ]*[′'][\t ]*([0-9\.]+)[\t ]*["″][\t ]*([NS])/gi, '$1{'+'{coord|$6|$7|$8|$9|$2|$3|$4|$5}'+'}');
 myContent.value = myContent.value.replace(/(\{\{[_ ]*CompetitionRecord[^\r\n\{\}]*)[\r\n]/g, '$1 ');
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*(CompetitionRecord)[_ ]*(\|)[\t ]*place[\t ]*=[\t ]*/g, '$1$2$3');
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*(CompetitionRecord(?:First|Second|Third))[_ ]*(\|)/g, '$1subst:$2$3');
 myContent.value = myContent.value.replace(/\*[\t\r\n ]*\{\{[_ A-Za-z_]*(https?:[^ \|\{\}]*)[_ ]*\}\}[\t\r\n ]([\r\n])/gi, '* $1$2');
 myContent.value = myContent.value.replace(/[\r\n][\t ]*\{\{[_ A-Za-z_]*(https?:[^ \|\{\}]*)[_ ]*\}\}[\t\r\n ]([\r\n])/gi, '$2$1$2');
 myContent.value = myContent.value.replace(/(<!--)[\t\r\n ]*\{\{[_ A-Za-z_]*(https?:[^ \|\{\}]*)[_ ]*\}\}[\t\r\n ]*(-->)/gi, '$1 $2 $3');
 myContent.value = myContent.value.replace(/>[\t\r\n ]*\{\{[_ A-Za-z_]*(https?:[^ \|\{\}]*)[_ ]*\}\}[\t\r\n ]*</gi, '>$1<');
 myContent.value = myContent.value.replace(/>[\t\r\n ]*\{\{[_ A-Za-z_]*(https?:[^ \|\{\}]*)[_ ]*\}?[\t\r\n ]*</gi, '>$1<');
 myContent.value = myContent.value.replace(/(=[\t ]*\{\{)[_ ]*(https?:[^ \|\{\}]*)/g, '$1URL|$2');
 myContent.value = myContent.value.replace(/\{\{[_ ]*(https?:[^ \|\{\}]*)[_ ]*\}\}/gi, '[$1]');
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*(https?:[^ \|\{\}=]*)[\t ]*\|([^\|{}]*\}\})/gi, '$1URL|$2|$3');
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*(https?:[^ \|\{\}]*)[\t ]*\|([^\|{}]*\}\})/gi, '$1URL|1=$2|2=$3');
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*(https?:[^ \|\{\}]*)/gi, '$1cite web|url=$2');
 myContent.value = myContent.value.replace(/\*[\t\r\n ]*\{[_ ]*(https?:[^ \|\{\}]*)[_ ]*\}\}?[\t\r\n ]([\r\n])/gi, '* $1$2');
 myContent.value = myContent.value.replace(/[\r\n][\t ]*\{[_ ]*(https?:[^ \|\{\}]*)[_ ]*\}\}?[\t\r\n ]([\r\n])/gi, '$2$1$2');
 myContent.value = myContent.value.replace(/(<!--)[\t\r\n ]*\{[_ ]*(https?:[^ \|\{\}]*)[_ ]*\}\}?[\t\r\n ]*(-->)/gi, '$1 $2 $3');
 myContent.value = myContent.value.replace(/>[\t\r\n ]*\{[_ ]*(https?:[^ \|\{\}]*)[_ ]*\}\}[\t\r\n ]*</gi, '>$1<');
 myContent.value = myContent.value.replace(/>[\t\r\n ]*\{[_ ]*(https?:[^ \|\{\}]*)[_ ]*\}?[\t\r\n ]*</gi, '>$1<');
 myContent.value = myContent.value.replace(/(=[\t ]*)(\{)[_ ]*(https?:[^ \|\{\}]*)/g, '$1$2$2URL|$3');
 myContent.value = myContent.value.replace(/\{[_ ]*(https?:[^ \|\{\}]*)[_ ]*\}\}/gi, '[$1]');
 myContent.value = myContent.value.replace(/(\{)[_ ]*(https?:[^ \|\{\}=]*)[\t ]*\|([^\|{}]*\}\})/gi, '$1$1URL|$2|$3');
 myContent.value = myContent.value.replace(/(\{)[_ ]*(https?:[^ \|\{\}]*)[\t ]*\|([^\|{}]*\}\})/gi, '$1$1URL|1=$2|2=$3');
 myContent.value = myContent.value.replace(/(\{)[_ ]*(https?:[^ \|\{\}]*)/gi, '$1$1cite web|url=$2');
 myContent.value = myContent.value.replace(/(\{)[_ ]*(?:ISBN|IBSN)(?:\-10|\-13)?[\t:\\\/= ]*([0-9\-X]+)[_ ]*(\}\})/gi, '$1ISBN|$2$3');
 
 myContent.value = myContent.value.replace(/(\{\{Galatasaray S)(K)(\||\}\}| )/g, '$1.$2.$3');
 
 myContent.value = myContent.value.replace(/(col_C[ ]*=[ ]*)#?ccffcc/gi, '$1green1');
 myContent.value = myContent.value.replace(/[\t ]*[\r\n]*[\t ]*[\r\n]*\{\{[_ ]*[Aa]rticle[_ ]+life[_ ]*\|[ ]*birth[ ]*=[\t ]*([^{}]*)\}\}[\t ]*[\r\n]*[\t ]*[\r\n]*/g, '\n==Article life==\n$1\n');
 myContent.value = myContent.value.replace(/((?:promoted|relegated|qualifiers)[\t ]*=[^\r\n]*)\{\{\-\}\}/g, '$1<br>');
 myContent.value = myContent.value.replace(/(?:[\t ]|\{\{\-\}\})+\&(?:[\t ]|\{\{\-\}\})+Qualified/g, ' and qualified');
 
 myContent.value = myContent.value.replace(/(\[\[[^\[\]\|]*)(, [A-Z][a-z]+)\|(\]\])[\t ]*\2/g, '$1$2$3');
 myContent.value = myContent.value.replace(/(\[\[)[\t ]*(\|)[\t ]*(\]\])/g, '$1 $2 $3');
 myContent.value = myContent.value.replace(/(\{\{)[_\t ]*[Hh](?:andball[\t_ ]+table[\t _]+row|bt\-row)/g, '$1fb cl2 team');
 myContent.value = myContent.value.replace(/(\{\{[_\t ]*[Ff]b[\t _]+cl2?[\t ]+(?:\{\{[^{}]*\}\}|[^{}])*)\|[ ]*bg[ ]*=[ ]*[Aa][ ]*(\||\}\})/g, '$1|bc=green1$2');
 myContent.value = myContent.value.replace(/(\{\{[_\t ]*[Ff]b[\t _]+cl2?[\t ]+(?:\{\{[^{}]*\}\}|[^{}])*)\|[ ]*bg[ ]*=[ ]*[Bb][ ]*(\||\}\})/g, '$1|bc=yellow1$2');
 myContent.value = myContent.value.replace(/(\{\{[_\t ]*[Ff]b[\t _]+cl2?[\t ]+(?:\{\{[^{}]*\}\}|[^{}])*)\|[ ]*bg[ ]*=[ ]*[Cc][ ]*(\||\}\})/g, '$1|bc=blue1$2');
 myContent.value = myContent.value.replace(/(\{\{[_\t ]*[Ff]b[\t _]+cl2?[\t ]+(?:\{\{[^{}]*\}\}|[^{}])*)\|[ ]*bg[ ]*=[ ]*[Ee][ ]*(\||\}\})/g, '$1|bc=red1$2');
 myContent.value = myContent.value.replace(/(\{\{[_\t ]*[Ff]b[\t _]+cl2?[\t ]+(?:\{\{[^{}]*\}\}|[^{}])*)\|[ ]*bg[ ]*=[ ]*[Oo][ ]*(\||\}\})/g, '$1|bc=lavender$2');
 myContent.value = myContent.value.replace(/(\{\{[_\t ]*[Ff]b[\t _]+cl2?[\t ]+(?:\{\{[^{}]*\}\}|[^{}])*)\|[ ]*bg[ ]*=[\t ]*(\||\}\})/g, '$1$2');
 myContent.value = myContent.value.replace(/(\{\{[_\t ]*[Ff]b[\t _]+cl2?[\t ]+(?:\{\{[^{}]*\}\}|[^{}])*)\|[ ]*(?:pts|points)[ ]*=[\t 0-9]*(\||\}\})/g, '$1$2');
 myContent.value = myContent.value.replace(/(\{\{[_\t ]*[Ff]b[\t _]+cl2?[\t ]+(?:\{\{[^{}]*\}\}|[^{}])*)\|[ ]*team[ ]*=/g, '$1|t=');
 
 myContent.value = myContent.value.replace(/(\{\{)[_\t ]*[Hh]andball[_\t ]+table[_\t ]+start[\t_ ]*(\||\}\})/g, '$1Fb cl header|winpoints=2|noqr=yes|nopos=yes$2');
 myContent.value = myContent.value.replace(/(\{\{)[_\t ]*[Hh]andball[_\t ]+table[_\t ]+end[\t_ ]*(\||\}\})/g, '$1end$2');
 
 //myContent.value = myContent.value.replace(/(\{\{#invoke:sports results[^{}]*\}\}[\t ]*[\r\n])[\t ]*[\r\n]*((?:<onlyinclude>|)\{\{#invoke:sports table[^{}]*\}\}(?:<\/onlyinclude>|)[\t ]*[\r\n])/g, '$2$1');
 myContent.value = myContent.value.replace(/([\t ]+was[\t ]+)performed[\t ]+in([\t ]+[0-9][0-9]*[\t ]+teams)/g, '$1contested by$2');
 myContent.value = myContent.value.replace(/(==)[^=\r\n]*r(esults round by round)/g, '$1R$2');
 
 myContent.value = myContent.value.replace(/(\{\{#invoke:sports table)(\|style=)/g, '$1|main$2');
 myContent.value = myContent.value.replace(/(\{\{[0-9]+)[\-–]([0-9]+ in European )[Ff](ootball)/g, '$1–$2f$3');
 myContent.value = myContent.value.replace(/(Chinese Jia-A League) ([0-9]+)/g, '$2 $1');
 myContent.value = myContent.value.replace(/(\[\[)(Primera[_ ]+División[_ ]+de[_ ]+México[_ ]+[A-Za-z]+)[_ ]+([0-9]+)[_ ]*(\||\]\])/g, '$1$3 $2$4');
 myContent.value = myContent.value.replace(/([0-9]+[snrt][tdh])[\t ]+Title/g, '$1 title');
 myContent.value = myContent.value.replace(/(\{\{winners(?:\{\{[^{}]*\}\}|[^{}])*)<br[ \/]*>([0-9]+[sthrnd]+)[ ]*title[ ]*(\}\})/g, '$1|$2$3');
 
 myContent.value = myContent.value.replace(/((?:<nowiki>|<!--)[^{}<>]*\{\{)/gi, '$1¶♦');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Aa]r(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|ar$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Aa]z(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|az$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Bb]e(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|be$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Bb]g(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|bg$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Bb]n(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|bn$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Bb]s(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|bs$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Cc]s(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|cs$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Dd]a(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|da$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Dd]e(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|de$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*(?:[Gg]r|[Ee]l)(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|el$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Ee]n(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|en$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Ee]s(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|es$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Ee]t(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|et$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Ee]u(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|eu$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Ff]a(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|fa$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Ff]i(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|fi$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Ff]r(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|fr$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Gg]l(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|gl$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Hh]e(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|he$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Hh]r(?:[\t ]+icon)[\t ]*(\}\})/g, '$1in lang|hr$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Hh]u(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|hu$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Hh]y(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|hy$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Ii]d(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|id$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Ii]s(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|is$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Ii]t(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|it$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Jj][ap](?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|ja$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Kk]a(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|ka$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Kk]k(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|kk$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Kk]o(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|ko$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Ll]a(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|la$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Ll]t(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|lt$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Ll]v(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|lv$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Mm]k(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|mk$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Mm]n(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|mn$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Mm]s(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|ms$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Nn]l(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|nl$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Nn]o(?:[\t ]+icon)[\t ]*(\}\})/g, '$1in lang|no$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Pp]l(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|pl$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Pp]t(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|pt$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Rr]o(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|ro$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Rr]u(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|ru$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Ss]k(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|sk$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Ss]l(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|sl$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Ss]q(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|sq$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Ss]r(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|sr$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Ss]v(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|sv$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Tt]h(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|th$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Tt]r(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|tr$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Uu]k(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|uk$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Uu]z(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|uz$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Vv]i(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|vi$2');
 myContent.value = myContent.value.replace(/([^\{]\{\{)[\t ]*[Zz]h(\-[a-z]+|)(?:[\t ]+icon|)[\t ]*(\}\})/g, '$1in lang|zh$2$3');
 myContent.value = myContent.value.replace(/(\{\{[_ \t ]*[Cc]ite[^{}]*\|[ ]*language[ ]*=[ ]*)\{\{in lang\|([a-z]+)\}\}/g, '$1$2');
 myContent.value = myContent.value.replace(/(\{\{)¶♦/g, '$1');
 
 if(myContent.value.search(/\{\{[0-9\-–]+[ ]+football in Portugal[ ]*\}\}/g) >= 0) {
 myContent.value = myContent.value.replace(/(\{\{[0-9\-–]+[ ]+)football in Portugal[ ]*(\}\})[\t ]*([\r\n])[\t ]*[\r\n]*((?:[\r\n]|.)*)/g, '$4$3$1in Portuguese football$2');
 myContent.value = myContent.value.replace(/(\[\[Category:[^\r\n]*[\r\n])[\t ]*[\r\n]*(\{\{[0-9\-–]+ in Portuguese football\}\})[\t ]*[\r\n]*/g, '$2\n$1');
 }
 myContent.value = myContent.value.replace(/(\{\{DEFAULTSORT:[^\r\n]*|\[\[Category:[^\r\n]*)([\r\n])(\{\{[0-9\-–]+ in Portuguese football\}\})/g, '$3$2$1');
 myContent.value = myContent.value.replace(/([\t ]*[\r\n])([\t ]*[\r\n])(\{\{[0-9\-–]+ in Portuguese football\}\})/g, '$1$3$2');
 
 myContent.value = myContent.value.replace(/!!width="30"\|<small>(\[\[[^\[\]]*\]\])<\/small>/g, '\n!$1');
 myContent.value = myContent.value.replace(/(\{\{winners[^{}]*\[\[File:[^\[\]]*)\|center(\]\])[ ]*([A-Z0-9])/g, '$1$2<br>$3');
 myContent.value = myContent.value.replace(/(\{\{winners[^{}]*[A-Za-z0-9])[ ]*(\[\[File:[^\[\]]*)\|center(\]\])/g, '$1<br>$2$3');
 
 myContent.value = myContent.value.replace(/(\|[ ]*col_[^=]*=[ ]*)#[dD]0[fF]0[cC]0/g, '$1green1');
 myContent.value = myContent.value.replace(/(\|[ ]*col_[^=]*=[ ]*)#[fF][fF][fF][fF]99/g, '$1yellow1');
 myContent.value = myContent.value.replace(/(\|[ ]*col_[^=]*=[ ]*)#[fF][bB][cC][eE][bB]1/g, '$1orange1');
 myContent.value = myContent.value.replace(/(\|[ ]*col_[^=]*=[ ]*)#[fF][fF][eE]4[bB]5/g, '$1orange2');
 if(0){
 if( myContent.value.search(/col_(P|R|QP|PP|QR|RP|EC|Q3|CWC|UC|IC)[ ]*=[ ]*#[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9](?:[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9]|)[^A-Fa-f0-9]/g) >= 0 ) {
 if( 'y' == prompt('normal colours?', 'y') ) {
 myContent.value = myContent.value.replace(/(\|[ ]*col_P=[ ]*)#[A-F0-9][A-F0-9][A-F0-9](?:[A-F0-9][A-F0-9][A-F0-9]|)([^A-F0-9])/gi, '$1green1$2');
 myContent.value = myContent.value.replace(/(\|[ ]*col_R=[ ]*)#[A-F0-9][A-F0-9][A-F0-9](?:[A-F0-9][A-F0-9][A-F0-9]|)([^A-F0-9])/gi, '$1red1$2');
 myContent.value = myContent.value.replace(/(\|[ ]*col_(?:QP|PP)=[ ]*)#[A-F0-9][A-F0-9][A-F0-9](?:[A-F0-9][A-F0-9][A-F0-9]|)([^A-F0-9])/gi, '$1green3$2');
 myContent.value = myContent.value.replace(/(\|[ ]*col_(?:QR|RP)=[ ]*)#[A-F0-9][A-F0-9][A-F0-9](?:[A-F0-9][A-F0-9][A-F0-9]|)([^A-F0-9])/gi, '$1red3$2');
 myContent.value = myContent.value.replace(/(\|[ ]*col_EC=[ ]*)#[A-F0-9][A-F0-9][A-F0-9](?:[A-F0-9][A-F0-9][A-F0-9]|)([^A-F0-9])/gi, '$1green1$2');
 myContent.value = myContent.value.replace(/(\|[ ]*col_Q3=[ ]*)#[A-F0-9][A-F0-9][A-F0-9](?:[A-F0-9][A-F0-9][A-F0-9]|)([^A-F0-9])/gi, '$1yellow1$2');
 myContent.value = myContent.value.replace(/(\|[ ]*col_CWC=[ ]*)#[A-F0-9][A-F0-9][A-F0-9](?:[A-F0-9][A-F0-9][A-F0-9]|)([^A-F0-9])/gi, '$1yellow1$2');
 myContent.value = myContent.value.replace(/(\|[ ]*col_[UI]C=[ ]*)#[A-F0-9][A-F0-9][A-F0-9](?:[A-F0-9][A-F0-9][A-F0-9]|)([^A-F0-9])/gi, '$1blue1$2');
 }
 }}
 
 myContent.value = myContent.value.replace(/((?:prev|next)season[ ]*=[ ]*\[\[)([0-9–]+)( [^\[\]\|]*)(\]\])/g, '$1$2$3|$2$4');
 if(myContent.value.search(/\{\{(?:20[0-9][0-9]|19[6-9][0-9]|1959)[ ]+football in Sweden[ ]*\}\}/g) >= 0) {
 myContent.value = myContent.value.replace(/(\{\{[0-9]+ )football in Sweden[ ]*(\}\})[\t ]*([\r\n])[\t ]*[\r\n]*((?:[\r\n]|.)*)/g, '$4$3$1in Swedish football$2');
 myContent.value = myContent.value.replace(/(\[\[Category:[^\r\n]*[\r\n])[\t ]*[\r\n]*(\{\{[0-9]+ in Swedish football\}\})[\t ]*[\r\n]*/g, '$2\n$1');
 }
 myContent.value = myContent.value.replace(/(\{\{DEFAULTSORT:[^\r\n]*|\[\[Category:[^\r\n]*)([\r\n])(\{\{[0-9]+ in Swedish football\}\})/g, '$3$2$1');
 myContent.value = myContent.value.replace(/([\t ]*[\r\n])([\t ]*[\r\n])(\{\{[0-9]+ in Swedish football\}\})/g, '$1$3$2');
 
 //myContent.value = myContent.value.replace(/(fb cl header)([^w\{\}]*\}\})/g, '$1|winpoints=2$2');
 myContent.value = myContent.value.replace(/(\|[ ]*extra information[ ]*=[\t ]*[\r\n])/g, '');

 //myContent.value = myContent.value.replace(/(\|[ ]*team[0-9]+[ ]*=[^\|\r\n]*)(\|[ ]*name_[^=]*=(?:\{\{[^{}]*\}\}|\[\[[^\[\]]*\]\]|[^\{\}\[\]\|])*)(\|[ ]*win_)/g, '$1\n$2\n$3');
 //myContent.value = myContent.value.replace(/(\|[ ]*(?:name_|win_)[^\r\n]*[\r\n])(\|[ ]*team[0-9]+[ ]*=[^\r\n]*[\r\n])/g, '$2$1');
 //myContent.value = myContent.value.replace(/(\|[ ]*(?:name_)[^\r\n]*[\r\n])(\|[ ]*(?:team[0-9]+[ ]*=|win_)[^\r\n]*[\r\n])/g, '$2$1');
 //myContent.value = myContent.value.replace(/(\|[ ]*team[0-9]+[ ]*=[^\r\n_]*)[\r\n](\|[ ]*team[0-9]+[ ]*=[^\|\=\{\}]*[\r\n])/g, '$1$2');
 myContent.value = myContent.value.replace(/(\{\{fb r2 header(?:\{\{[^{}]*\}\}|\[\[[^\[\]]*\]\]|[^\[\]{}])*)[\t ][\t ]*\|/g, '$1|');
 myContent.value = myContent.value.replace(/(\{\{fb r2 header(?:\{\{[^{}]*\}\}|\[\[[^\[\]]*\]\]|[^\[\]{}])*)\|[\t ][\t ]*/g, '$1|');
 myContent.value = myContent.value.replace(/(\{\{fb r2 header(?:\{\{[^{}]*\}\}|\[\[[^\[\]]*\]\]|[^\[\]{}])*)[\|\t ](\}\})/g, '$1$2');

 myContent.value = myContent.value.replace(/(\{\{VFA\/VFL seasons\}\}[\t ]*[\r\n]*)\{\{(?:Aussie Rules in Victoria|VFL)\}\}[\t ]*[\r\n]*/gi, '$1');
 myContent.value = myContent.value.replace(/(\{\{VFA\/VFL seasons\}\}[\t ]*[\r\n]*)\{\{(?:Aussie Rules in Victoria|VFL)\}\}[\t ]*[\r\n]*/gi, '$1');
 myContent.value = myContent.value.replace(/(?:<center>|[\t ]|[\r\n])*\{\|[^\r\n]*[\r\n](?:\|\-[^\r\n]*[\r\n]|)\|[\t ]*colspan[^\r\n]*[\r\n]\{\|[^\r\n]*[\r\n](?:\|\-[^\r\n]*[\r\n]|)\|[^\r\n\|]*\|[\t ]*[\r\n]\|[^\r\n\|]*\|[\t ']*([0-9A-Za-z ]*)[' ]*[\r\n]\|[^\r\n\|]*\|[\t ]*[\r\n]\|\}[^\r\n]*[\r\n](?:\|\-[^\r\n]*[\r\n]|)/g, '\n{| class="wikitable"\n|+ $1\n');
 myContent.value = myContent.value.replace(/\{\|[^\r\n]*[\r\n]\|\+ ([^\r\n]*)[\r\n]![\t ]*!![\t ]*TEAM[\t ]*!!(?:[^\|!\r\n]*\||[\t ])*P[\t ]*!!(?:[^\|!\r\n]*\||[\t ])*W[\t ]*!!(?:[^\|!\r\n]*\||[\t ])*L[\t ]*!!(?:[^\|!\r\n]*\||[\t ])*D[\t ]*!!(?:[^\|!\r\n]*\||[\t ])*PF[\t ]*!!(?:[^\|!\r\n]*\||[\t ])*PA[\t ]*!!(?:[^\|!\r\n]*\||[\t ])*Pct[\t ]*!!(?:[^\|!\r\n]*\||[\t ])*PTS/g, '{'+'{fb cl header|title=$1|loss_before_draw=true|for_against_style=points|use_goal_percentage=y|winpoints=4|drawpoints=2|status_text_P=Premiers}'+'}');
 myContent.value = myContent.value.replace(/\|\-[\t ]*style=[" ]*font-size:[ ]*xx-small[;" ]*[\r\n]\|[ ]*colspan[^\r\n]*[\r\n]\|[\t ]*colspan[ ]*=[" ]*2[" ]*\|[\t ]*([^\r\n]*)[\r\n]\|\}/g, '|-\n{'+'{fb cl footer|orfc=1) points; 2) percentage; 3) number of points for.}' + '}$1');
 myContent.value = myContent.value.replace(/(\{\{fb cl footer[^{}]*)(\}\})[\t ]*(?:Source\.?|)[\t ]*(<ref[^\r\n]*)/g, '$1|s=$3$2');
 
 myContent.value = myContent.value.replace(/\{\|[^\r\n]*[\r\n](?:\|\-[^\r\n]*[\r\n]|)\|[' ]*Home[ ]*.[ ]*Away[' ]*[^\r\n\|]*/g, '{'+'{fb r2 header|nt=0}'+'}');
 myContent.value = myContent.value.replace(/(\{\{fb r2 header[^{}]*\}\})[\t ]*\|\|/g, '$1\n|');
 myContent.value = myContent.value.replace(/(\{\{fb r2 header[^{}]*\}\})[\t ]*[\r\n]\|[ ]*width[ ]*=[ ]*[^\|]*/g, '$1\n');
 if(myContent.value.search(/\{\{fb r2 header\|nt=[0-9]+[^{}]*\}\}[\t ]*[\r\n]\|(?:\[\[[^\[\]]*\]\]|\{\{[^{}]*\}\}|[^\[\]\{\}\|\r\n\-\}])(?:\[\[[^\[\]]*\]\]|\{\{[^{}]*\}\}|[^\[\]\{\}\|\r\n])*(?:\|\||[\r\n])/) >=0 ) {
 myContent.value = myContent.value.replace(/(\{\{fb r2 header[^{}]*\}\}[\t ]*[\r\n])!/g, '$1| ');
 var nt = (myContent.value.match(/\{\{fb r2 header\|nt=([0-9]+)[^{}]*\}\}[\t ]*[\r\n]\|(?:\[\[[^\[\]]*\]\]|\{\{[^{}]*\}\}|[^\[\]\{\}\|\r\n\-\}])(?:\[\[[^\[\]]*\]\]|\{\{[^{}]*\}\}|[^\[\]\{\}\|\r\n])*(?:\|\||[\r\n])/))[1];
 nt = Number(nt) + 1;
 myContent.value = myContent.value.replace(/(\{\{fb r2 header\|nt)=[0-9]+([^{}]*)(\}\})[\t ]*[\r\n]\|((?:\[\[[^\[\]]*\]\]|\{\{[^{}]*\}\}|[^\[\]\{\}\|\r\n\-\}])(?:\[\[[^\[\]]*\]\]|\{\{[^{}]*\}\}|[^\[\]\{\}\|\r\n])*)((?:\|\||[\r\n]))/, '$1=' + nt + '$2|$4$3$5');
 }
 myContent.value = myContent.value.replace(/(\{\{fb r2 header[^{}]*)'''/g, '$1');
 myContent.value = myContent.value.replace(/(\{\{fb r2 header[^{}]*)\|\|/g, '$1|');
 myContent.value = myContent.value.replace(/(\{\{fb r2 team\|t=)[ ]*\|[ ]*align[ ]*=[" ]*left[" ]*\|/g, '$1');

 myContent.value = myContent.value.replace(/[\t ]*[\r\n][\t ]*([\r\n]\{\{:[^{}]*\}\})/g, '$1');
 myContent.value = myContent.value.replace(/(\{\{:[^{}]*\}\}[\r\n])[\t ]*[\r\n][\t ]*/g, '$1');
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*(?:[Ii]nfobox[_ ]+[Ww]ebsite(?:\/[Ww]ith[_ ]*logo|[_ ]+with[_]+IPv6|2|)|[Ii]nfobox[_ ]+[Dd]ot[\-_ ]*[Cc]om[_ ]+[Cc]ompany|[Dd]otcom[_ ]+company|[Ii]nfobox[_ ]+dotcom|[Ii]nfobox[_ ]+(?:web|site))((?:<!--[^<>]*-->|[\t ]|[\r\n])*\|)/g, '$1Infobox website$2');
 myContent.value = myContent.value.replace(/(\{\{Infobox website(?:\{\{[^{}]*\}\}|[^{}])*)[\t ]*\|[\t ]*(?:slogan)[\t ]*=[\t ]*[\r\n]*([\t ]*\||[\t ]*\}\})/g, '$1$2');
 myContent.value = myContent.value.replace(/(\{\{Infobox website(?:\{\{[^{}]*\}\}|[^{}])*)[\t ]*\|[\t ]*(?:company_slogan)[\t ]*=[\t ]*[\r\n]*([\t ]*\||[\t ]*\}\})/g, '$1$2');
 myContent.value = myContent.value.replace(/(\{\{Infobox website(?:\{\{[^{}]*\}\}|[^{}])*)[\t ]*\|[\t ]*(?:ip)[\t ]*=[\t ]*[\r\n]*([\t ]*\||[\t ]*\}\})/g, '$1$2');
 myContent.value = myContent.value.replace(/(\{\{Infobox website(?:\{\{[^{}]*\}\}|[^{}])*\|[ ]*)(?:slogan )([\t ]*=)/g, '$1logo_caption$2');
 myContent.value = myContent.value.replace(/(\{\{Infobox website(?:\{\{[^{}]*\}\}|[^{}])*\|[ ]*)(?:slogan)[\t ]*( =)/g, '$1logo_caption$2');
 myContent.value = myContent.value.replace(/(\{\{Infobox website(?:\{\{[^{}]*\}\}|[^{}])*\|[ ]*)(?:slogan)[\t ]*(=)/g, '$1logo_caption$2');
 myContent.value = myContent.value.replace(/(\{\{Infobox website(?:\{\{[^{}]*\}\}|[^{}])*\|[ ]*)(?:company_slogan)([\t ]*=)/g, '$1logo_caption$2');
 myContent.value = myContent.value.replace(/(\{\{Infobox website(?:\{\{[^{}]*\}\}|[^{}])*\|[ ]*)(?:launch date)([\t ]*=)/g, '$1launch_date$2');
 myContent.value = myContent.value.replace(/(\{\{Infobox website(?:\{\{[^{}]*\}\}|[^{}])*\|[ ]*)(?:current status)([\t ]*=)/g, '$1current_status$2');
 myContent.value = myContent.value.replace(/(\{\{Infobox website(?:\{\{[^{}]*\}\}|[^{}])*\|[ ]*)(?:content license)([\t ]*=)/g, '$1content_license$2');
 myContent.value = myContent.value.replace(/(\{\{Infobox website(?:\{\{[^{}]*\}\}|[^{}])*\|[ ]*)(?:content licence)([\t ]*=)/g, '$1content_licence$2');
 myContent.value = myContent.value.replace(/\|[ ]*bg[ ]*=[ ]*\{\{\{bgc\}\}\}[ ]*[\r\n]?/g, '');
 myContent.value = myContent.value.replace(/(<section begin[^<>]*>)[\t ]*[\r\n][\t ]*(\{\{)/g, '$1$2');
 myContent.value = myContent.value.replace(/[\t ]*[\r\n][\t ]*(<section end[^<>]*>)/g, '$1');
 myContent.value = myContent.value.replace(/\|[ ]*showteam[ ]*=[ ]*only_pld_pts[ ]*=[\t ]*[\r\n]*[\t ]*\|[\t ]*show_matches[\t ]*=[\t ]*no/g, '');
 myContent.value = myContent.value.replace(/\|[ ]*showteam[ ]*=[ ]*only_pld_pts[ ]*=[\t ]*[\r\n]*/g, '');
 myContent.value = myContent.value.replace(/(\{\{)[\t_ ]*(?:[Tt]emplate[_ ]+doc|[Tt]emplate[_ ]+documentation||[Dd]ocumentation|[Dd]ocumentation[_ ]+template|[Dd]ocs?|[Dd]ocumentation\/core|[Dd]OC|[Dd]okumentation)[\t_ ]*(\}\})/g, '$1subst:#ifexist:$1subst:#invoke:string|replace|$1subst:FULLPAGENAME$2|/sandbox$|plain=false$2/doc|$1{'+'{subst:void}'+'}documentation$2$2');
 myContent.value = myContent.value.replace(/[ ]*\|[ ]*showteam[ ]*=[ ]*\{\{\{showteam\|?\}\}\}[ ]*[\r\n]*[ ]*/g, '');
 myContent.value = myContent.value.replace(/[ ]*\|[ ]*only_pld_pts[ ]*=[ ]*\{\{\{only_pld_pts\|?\}\}\}[ ]*/g, '');
 myContent.value = myContent.value.replace(/[ ]*\|[ ]*show_matches[ ]*=[ ]*\{\{\{show_matches\|?\}\}\}[ ]*/g, '');
 myContent.value = myContent.value.replace(/[ ]*\|[ ]*show_limit[ ]*=[ ]*\{\{\{show_limit\|?\}\}\}[ ]*/g, '');
 myContent.value = myContent.value.replace(/[ ]*\|[ ]*draw_header[ ]*=[ ]*<abbr title="Tied">T<\/abbr>[ ]*\|[ ]*loss_before_draw[ ]*=/g, '|use_tie=y|loss_before_tie=');
 myContent.value = myContent.value.replace(/[ ]*\|[ ]*draw_header[ ]*=[ ]*<abbr title="Tied">T<\/abbr>[ ]*/g, '|use_tie=y');
 myContent.value = myContent.value.replace(/(\|[ ]*style[ ]*=[ ]*)football[\t ]*([\r\n]|\|)[\t ]*[\r\n]*/g, '$1WDL$2');
 myContent.value = myContent.value.replace(/(\{\{[_ ]*#[Ii]nvoke:[ ]*[Ss]ports[_ ]+table(?:\{\{[^{}]*\}\}|[^{}]|\{\{\{teamwidth\}\}\})*)[ ]*\|[ ]*template_name[ ]*=[ ]*(?:[Tt]emplate:|)[^:<> \|][^:<>\|{}]*((?:<!--[^<>]*-->[\t \r\n]*|)\|)/g, '$1$2');
 myContent.value = myContent.value.replace(/^[\t \r\n]*(\{\{[_ ]*#[Ii]nvoke:[ ]*[Ss]ports[_ ]+table(?:\{\{[^{}]*\}\}|[^{}]|\{\{\{[a-z_\|0-9]+\}\}\})*\}\})[\t \r\n]*(<)/g, '$1$2');
 myContent.value = myContent.value.replace(/(>)[\t \r\n]*(\{\{[_ ]*#[Ii]nvoke:[ ]*[Ss]ports[_ ]+table(?:\{\{[^{}]*\}\}|[^{}]|\{\{\{[a-z_\|0-9]+\}\}\})*\}\})[\t \r\n]*(<)/g, '$1$2$3');
 
 myContent.value = myContent.value.replace(/(\[\[Category:[A-Za-z0-9 ]+\]\])[\t ]*[\r\n]((?:\[\[[^\[\]]*\]\]|[\t\r\n ])*)\1/g, '$2$1');
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*(?:NCAATeamSeason|NCAA team season|Infobox NCAA team season)/g, '$1Infobox college sports team season');
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*([Ii]nfobox[_ ]+college[_ ]+sports[_ ]+team[_ ]+season[\t ]*)[\r\n]*([\t ]*\|[\t ]*)/g, '$1$2\n$3sport=football\n$3');
 myContent.value = myContent.value.replace(/(\{\{[_ ]*[Ii]nfobox[_ ]+college[_ ]+sports[_ ]+team[_ ]+season(?:\{\{[^{}]*\}\}|[^{}])*\|[ ]*)[Mm]ode ?([ ]*=)/g, '$1sport$2');
 if (myContent.value.search(/\{\{[_ ]*[Ii]nfobox[_ ]+college[_ ]+sports[_ ]+team[_ ]+season[^{}]*\|[ ]*year[ ]*=[ ]*[0-9\––]+/g) >= 0) {
 var yr = (myContent.value.match(/\{\{[_ ]*[Ii]nfobox[_ ]+college[_ ]+sports[_ ]+team[_ ]+season[^{}]*\|[ ]*year[ ]*=[ ]*([0-9\––]+)/))[1];
 yr = yr.replace(/^[\t ]*([0-9][0-9][0-9][0-9])[\-–]([0-9]+)[\t ]*$/g, '$1-$2');
 yr = yr.replace(/^([0-9][0-9])([0-9][0-9])[\-–]([0-9][0-9])$/g, '$1$2-$1$3');
 var pyr = 0;
 var nyr = 0;
 if (yr.search(/^[0-9][0-9][0-9][0-9]\-[0-9][0-9][0-9][0-9]$/) >= 0) {
 yr = (yr.match(/^([0-9][0-9][0-9][0-9])\-([0-9][0-9][0-9][0-9])/))[1];
 pyr = (Number(yr) - 1) + '-' + Number(yr);
 nyr = (Number(yr) + 1) + '-' + (Number(yr) + 2);
 yr = Number(yr) + '-' + (Number(yr) + 1);
 yr = yr.replace(/^([0-9][0-9])([0-9][0-9]\-)\1/g, '$1$2');
 pyr = pyr.replace(/^([0-9][0-9])([0-9][0-9]\-)\1/g, '$1$2');
 nyr = nyr.replace(/^([0-9][0-9])([0-9][0-9]\-)\1/g, '$1$2');

 var re1 = new RegExp('(\\{\\{[_ ]*[Ii]nfobox[_ ]+college[_ ]+sports[_ ]+team[_ ]+season(?:\\{\\{[^{}]*\\}\\}|[^{}])*)\\|[ ]*prev_year[ ]*=[\\t ]*' + pyr + '[\\t\\r\\n ]*(\\||\\}\\})', 'g');
 var re2 = new RegExp('(\\{\\{[_ ]*[Ii]nfobox[_ ]+college[_ ]+sports[_ ]+team[_ ]+season(?:\\{\\{[^{}]*\\}\\}|[^{}])*)\\|[ ]*next_year[ ]*=[\\t ]*' + nyr + '[\\t\\r\\n ]*(\\||\\}\\})', 'g');
 myContent.value = myContent.value.replace(re1, '$1$2');
 myContent.value = myContent.value.replace(re2, '$1$2');
 pyr = pyr.replace(/[\-]/g, '–');
 nyr = nyr.replace(/[\-]/g, '–');
 re1 = new RegExp('(\\{\\{[_ ]*[Ii]nfobox[_ ]+college[_ ]+sports[_ ]+team[_ ]+season(?:\\{\\{[^{}]*\\}\\}|[^{}])*)\\|[ ]*prev_year[ ]*=[\\t ]*' + pyr + '[\\t\\r\\n ]*(\\||\\}\\})', 'g');
 re2 = new RegExp('(\\{\\{[_ ]*[Ii]nfobox[_ ]+college[_ ]+sports[_ ]+team[_ ]+season(?:\\{\\{[^{}]*\\}\\}|[^{}])*)\\|[ ]*next_year[ ]*=[\\t ]*' + nyr + '[\\t\\r\\n ]*(\\||\\}\\})', 'g');
 myContent.value = myContent.value.replace(re1, '$1$2');
 myContent.value = myContent.value.replace(re2, '$1$2');
 } else if (yr.search(/^[0-9][0-9][0-9][0-9]$/) >= 0) {
 pyr = Number(yr) - 1;
 nyr = Number(yr) + 1
 var re1 = new RegExp('(\\{\\{[_ ]*[Ii]nfobox[_ ]+college[_ ]+sports[_ ]+team[_ ]+season(?:\\{\\{[^{}]*\\}\\}|[^{}])*)\\|[ ]*prev_year[ ]*=[\\t ]*' + pyr + '[\\t\\r\\n ]*(\\||\\}\\})', 'g');
 var re2 = new RegExp('(\\{\\{[_ ]*[Ii]nfobox[_ ]+college[_ ]+sports[_ ]+team[_ ]+season(?:\\{\\{[^{}]*\\}\\}|[^{}])*)\\|[ ]*next_year[ ]*=[\\t ]*' + nyr + '[\\t\\r\\n ]*(\\||\\}\\})', 'g');
 myContent.value = myContent.value.replace(re1, '$1$2');
 myContent.value = myContent.value.replace(re2, '$1$2');
 }
 }
 myContent.value = myContent.value.replace(/(\{\{[_ ]*[Ii]nfobox[_ ]+college[_ ]+sports[_ ]+team[_ ]+season[\t ]*[\r\n])[\t ]*\|[\t ]*sport[ ]*=[ ]*football[\t ]*[\r\n]((?:\{\{(?:\{\{[^{}]*\}\}|[^{}])*\}\}|[^{}])*\|[ ]*sport[ ]*=)/g, '$1$2');
 myContent.value = myContent.value.replace(/([\r\n][\t ]*\|[\t ]*sport[\t ]*=[\t ]*[A-Za-z\t ]*)([\r\n][\t ]*\|[\t ]*year[\t ]*=[\t ]*[^\r\n]*)([\r\n][\t ]*\|)/g, '$2$1$3');
 myContent.value = myContent.value.replace(/([\r\n][\t ]*\|[\t ]*sport[\t ]*=[\t ]*[A-Za-z\t ]*)([\r\n][\t ]*\|[\t ]*team[\t ]*=[\t ]*[^\r\n]*)([\r\n][\t ]*\|)/g, '$2$1$3');
 myContent.value = myContent.value.replace(/(\{\{[_ ]*[Ii]nfobox[_ ]+college[_ ]+sports[_ ]+team[_ ]+season[\t ]*[\r\n](?:\{\{(?:\{\{[^{}]*\}\}|[^{}])*\}\}|[^{}])*\|[\t ]*sport[ ]*=[ ]*[^Ff\t ](?:\{\{(?:\{\{[^{}]*\}\}|[^{}])*\}\}|[^{}])*\|[ ]*)bowl[ ]*( =)/g, '$1tourney$2');
 myContent.value = myContent.value.replace(/(\{\{[_ ]*[Ii]nfobox[_ ]+college[_ ]+sports[_ ]+team[_ ]+season[\t ]*[\r\n](?:\{\{(?:\{\{[^{}]*\}\}|[^{}])*\}\}|[^{}])*\|[\t ]*sport[ ]*=[ ]*[^Ff\t ](?:\{\{(?:\{\{[^{}]*\}\}|[^{}])*\}\}|[^{}])*\|[ ]*)bowl[ ]*(=)/g, '$1tourney$2');
 myContent.value = myContent.value.replace(/(\{\{[_ ]*[Ii]nfobox[_ ]+college[_ ]+sports[_ ]+team[_ ]+season[\t ]*[\r\n](?:\{\{(?:\{\{[^{}]*\}\}|[^{}])*\}\}|[^{}])*\|[\t ]*sport[ ]*=[ ]*[^Ff\t ](?:\{\{(?:\{\{[^{}]*\}\}|[^{}])*\}\}|[^{}])*\|[ ]*)bowl_result[ ]*( =)/g, '$1tourney_result$2');
 myContent.value = myContent.value.replace(/(\{\{[_ ]*[Ii]nfobox[_ ]+college[_ ]+sports[_ ]+team[_ ]+season[\t ]*[\r\n](?:\{\{(?:\{\{[^{}]*\}\}|[^{}])*\}\}|[^{}])*\|[\t ]*sport[ ]*=[ ]*[^Ff\t ](?:\{\{(?:\{\{[^{}]*\}\}|[^{}])*\}\}|[^{}])*\|[ ]*)bowl_result[ ]*(=)/g, '$1tourney_result$2');
 myContent.value = myContent.value.replace(/(\|[ ]*source[ ]*=)[ ]*[\r\n]([^{}]*\}\}(?:\{\{[^{}]*\}\}|[\r\n]\{\||[\r\n]\|\}|[^{}])*)(https?:\/\/www\.rsssf\.com[^ \]]*nedamahist\.html)/g, '$1[$3 rsssf.com]\n$2$3');
 }
 myContent.value = myContent.value.replace(/(\|[ ]*label[ ]*=[ ]*)[\t ]*[\r\n]*<div style="font\-size:([0-9]+)%[;" ]*>((?:[^<>]|<br[^<>]*>)*)<\/div>/g, '|label_size=$2$1$3');
 myContent.value = myContent.value.replace(/(\|[ ]*label[ ]*=[ ]*[\t ]*[\r\n]*<div style=")font\-size:([0-9]+)%[; ]*/g, '|label_size=$2$1');
 myContent.value = myContent.value.replace(/(\|[ ]*source[ ]*=)[ ]*[\r\n]([^{}]*\}\}(?:\{\{[^{}]*\}\}|[\r\n]\{\||[\r\n]\|\}|[^{}])*[ \[\*])(https?:\/\/www\.rsssf\.com[^ \t\r\n\]]*)/g, '$1[$3 rsssf.com]\n$2$3');
 if (count > 999) alert('Breaking first loop!');

 if (mw.config.get('wgNamespaceNumber') == 10) {
 myContent.value = myContent.value.replace(/(\{\{[Nn]avbox[^{}]*\|[ ]*name[ ]*=)[^\|\r\n{}]*([\r\n])/g, '$1 {'+'{subst:#invoke:string|replace|'+'{'+'{subst:#invoke:string|replace|'+'{'+'{subst:PAGENAME}'+'}|&#39;|\'}'+'}|&#38;|&}'+'}$2');
 myContent.value = myContent.value.replace(/([^\}])(\}\})([\t \r\n]*)(<noinclude>)/gi, '$1$3$2$4');
 myContent.value = myContent.value.replace(/\|[ ]*liststyle[ ]*=[ ]*font\-size[\t ]*:[\t ]*95%[;\t ]*([\r\n])/g, '$1');
 if (myContent.value != '' && myContent.value.search(/\[\[[_ ]*[Cc]ategory[_ ]*:/g) < 0 && myContent.value.search(/documentation\}\}/i) < 0 && myContent.value.search(/\{\{R /i) < 0 ) {
 alert('No categories?');
 }
 }
 if (mw.config.get('wgNamespaceNumber') != 0 ) {
 return;
 }

 lt = '';
 
 // myContent.value = myContent.value.replace(/(<div style="font\-size[^<>]*>(?:[^\r\n<>]|<br[^<>]*>)*)[\r\n]([^\*;:])/g, '$1$2');
 count = 0;
 while(lt != myContent.value && count < 1000) {
 lt = myContent.value;
 count = count + 1;
 myContent.value = myContent.value.replace(/cellpadding="4" cellspacing="0" style="margin: 1em 1em 1em 0; background: #f9f9f9; border: 1px #aaa solid; border-collapse: collapse; font-size: 100%;"/gi, 'class="wikitable"');
 myContent.value = myContent.value.replace(/bgcolor="#B0C4DE" align="center"[\t ]*([\r\n])\|/gi, '$1!');
 
 myContent.value = myContent.value.replace(/(\{\{)col\-begin(\}\})[\t ]*[\r\n]*[\t ]*[\r\n]*\{\{col\-[1-4]\}\}[\t ]*[\r\n]*[\t ]*([\r\n][\*#:])/gi, '$1colbegin|colwidth=18em$2<!-- ' + 'KILL COLUMNS -->$3');
 myContent.value = myContent.value.replace(/(<!--[ ]*KILL COLUMNS[ ]*-->)[\t ]*\{\{col\-[1-4]\}\}[\t ]*[\r\n]*/gi, '$1');
 myContent.value = myContent.value.replace(/<!--[ ]*KILL COLUMNS[ ]*-->[\t ]*(\{\{col)[\- ](end\}\})/gi, '$1$2');
 myContent.value = myContent.value.replace(/(<!--[ ]*KILL COLUMNS[ ]*-->)([^\r\n]*)/g, '$2$1');
 myContent.value = myContent.value.replace(/(<!--[ ]*KILL COLUMNS[ ]*-->)([\r\n])/g, '$2$1');
 
 myContent.value = myContent.value.replace(/(¶♦[^\r\n]*)<\/center>/gi, '$1');
 myContent.value = myContent.value.replace(/(¶♦[^\r\n]*)<center>/gi, '$1 ');
 myContent.value = myContent.value.replace(/(¶♦[^\r\n]*)<\/span>/gi, '$1');
 myContent.value = myContent.value.replace(/(¶♦[^\r\n]*)<span[^<>]*>/gi, '$1 ');
 myContent.value = myContent.value.replace(/(¶♦\|\-[\t ]*)![\t ]*/gi, '$1 ');
 myContent.value = myContent.value.replace(/(¶♦[^\r\n]*\|)[\t ]*!bgcolor[^\r\n\|]*\|[\t ]*/g, '$1');
 myContent.value = myContent.value.replace(/¶♦(\|\}|\{\{end\}\})/gi, '$1');
 myContent.value = myContent.value.replace(/(¶♦)([^\r\n]*[\r\n])/g, '$2$1');
 }
 if (count > 999) alert('Breaking second loop!');
 lt = '';
 count = 0;
 myContent.value = myContent.value.replace(/(\{\{colbegin[^{}]*\}\}[\t ]*[\r\n]\*[^\r\n]*[\r\n])(:[^\r\n]*[\r\n])/gi, '$1*$2<!--' + 'INDENT -->');
 while(lt != myContent.value && count < 1000) {
 lt = myContent.value;
 count = count + 1;
 myContent.value = myContent.value.replace(/(<!--[ ]*INDENT[ ]*-->)([\t ]*[\r\n]|\*[^\r\n]*[\r\n])/g, '$2$1');
 myContent.value = myContent.value.replace(/(<!--[ ]*INDENT[ ]*-->)(:[^\r\n]*[\r\n])/g, '*$2$1');
 myContent.value = myContent.value.replace(/<!--[ ]*INDENT[ ]*-->([\t ]*[\r\n]*\{\{colend\}\})/g, '$1');
 }
 if (count > 999) alert('Breaking Second loop!');
 
 var tname = mw.config.get('wgTitle');
 var endyr = tname.replace(/^([0-9–]+) .*$/, '$1');
 tname = tname.replace(/^[0-9–]+ (.*) season$/, '$1');
 endyr = endyr.replace(/^[0-9][0-9][0-9][0-9]–([0-9][0-9][0-9][0-9])/, '$1');
 endyr = endyr.replace(/^([0-9][0-9])[0-9][0-9]–([0-9][0-9])/, '$1$2');
 myContent.value = myContent.value.replace(/![^\|\r\n]*\|Pos[^\r\n]*[\r\n]![^\|\r\n]*\|Team[^\r\n]*[\r\n]![^\|\r\n]*\|W[^\r\n]*[\r\n]![^\|\r\n]*\|D[^\r\n]*[\r\n]![^\|\r\n]*\|L[^\r\n]*[\r\n]![^\|\r\n]*\|F[^\r\n]*[\r\n]![^\|\r\n]*\|A[^\r\n]*[\r\n]![^\|\r\n]*\|Pts/g, '|Pos|' + '|Club|' + '|P|' + '|W|' + '|D|' + '|L|' + '|GF|' + '|GA|' + '|Pts');
 myContent.value = myContent.value.replace(/ in season ([0-9]+)\-([0-9]+)/g, ' for the $1–$2 season');
 myContent.value = myContent.value.replace(/(Statistics of )(\[\[[^\[\]]*\]\] for the)/g, '$1the $2');
 myContent.value = myContent.value.replace(/(\{\{winners[^{}]*[0-9]+)\-/g, '$1–');
 myContent.value = myContent.value.replace(/(\{\{winners[^{}]*):(\|)/g, '$1$2');

 myContent.value = myContent.value.replace(/(\{\{fb cl[^{}]*)\|noqr=y([^{}]*\}\})[\t ]*(?:[\r\n]![^\|\r\n]*\|Result|\|\|[ ]*Notes?)[\t ]*[\r\n]/g, '$1$2\n');
 myContent.value = myContent.value.replace(/(\[\[)(UEFA Cup) ([0-9]+)[\-–]([0-9]+)/g, '$1$3–$4 $2');
 myContent.value = myContent.value.replace(/(\{\{reflist)\|[1-8](\}\})/gi, '$1$2');

 myContent.value = myContent.value.replace(/(\|[\s]*)dead\-?url([\s]*=[\s]*)(?:1|[Yy][Ee][Ss]|[Yy]|[Tt][Rr][Uu][Ee])([\s]*\||[\s]*\}\})/g, '$1url-status$2dead$3');
 myContent.value = myContent.value.replace(/(\|[\s]*)dead\-?url([\s]*=[\s]*)(?:0|[Nn][Oo]|[Nn]|[Ff][Aa][Ll][Ss][Ee])([\s]*\||[\s]*\}\})/g, '$1url-status$2live$3');
 myContent.value = myContent.value.replace(/(\{\{0)(\}\})\{\{0\}\}\{\{0\}\}\{\{0\}\}/g, '$1|0000$2');
 myContent.value = myContent.value.replace(/(\{\{fb r2 team[^{}]*)'''/g, '$1');
 myContent.value = myContent.value.replace(/(\{\{fb r2 team[^{}]*)'''/g, '$1');
 myContent.value = myContent.value.replace(/(\*[ ]*\[\[)((?:Persian Gulf Pro League|Azadegan League|Iran Football's (?:2nd|3rd) Division|Hazfi Cup|Iranian Futsal Super League|Persian Gulf Cup))[ ]*([0-9]+)[^0-9]([0-9]+)(?:\|[ ]*[A-Z][^\[\]\|]*[0-9]+[ ]*|)(\]\])/g, '$1$3–$4 $2$5');
 myContent.value = myContent.value.replace(/(\*[ ]*\[\[[0-9]+)[^0-9]([0-9]+ (?:Persian Gulf Pro League|Azadegan League|Iran Football's (?:2nd|3rd) Division|Hazfi Cup|Iranian Futsal Super League|Persian Gulf Cup))[ ]*(?:\|[ ]*[A-Z][^\[\]\|]*[0-9]+[ ]*|)(\]\])/g, '$1–$2$3');
 if( myContent.value.search(/\[\[Category:[0-9–]+ in Romanian football[ ]*(?:\||\])/g) >= 0 && myContent.value.search(/\{\{[_ ]*Football in Romania/g) >= 0) {
 var t = (myContent.value.match(/\[\[Category:[0-9–]+ in Romanian football[ ]*(?:\||\])/g))[0];
 t = t.replace(/^\[\[Category:/, '');
 t = t.replace(/[\s\|\]]*$/, '');
 myContent.value = myContent.value.replace(/[\s]*(\{\{)[\s]*Football in Romania[\s]*(\}\})/gi, '\n$1'+t+'$2');
 myContent.value = myContent.value.replace(/(\{\{)([^{}]* in Romanian football)(\}\})/g, '$1subst:#ifexist:Template:$2|$1$1subst:void$3$2$3|<$1subst:void$3!--$1$1subst:void$3$2$3-->$3');
 }
 myContent.value = myContent.value.replace(/(=[ ]*Final)[\t ]+Standing/g, '$1 standing');
 myContent.value = myContent.value.replace(/(\[\[|\{\{main\|)(Campeonato Brasileiro Série [A-Z]) ([0-9]+)/g, '$1$3 $2');

 myContent.value = myContent.value.replace(/[\r\n][' ]*For more information[, ]+see[ ]+\[\[([^\[\]\|]*)\]\][' ]*/g, '\n{'+'{main|$1}'+'}');
 
 myContent.value = myContent.value.replace(/\{\{[_ ]*[Ff]ootball[_ ]+in[_ ]+Scotland[_ ]*\}\}[\t ]*[\r\n]*/g, '');
 myContent.value = myContent.value.replace(/(\[\[)(European Cup|European Cup Winners' Cup|UEFA Cup Winners' Cup|Inter\-Cities Fairs Cup|FA Cup) ([0-9][0-9][0-9][0-9])[\-–]([0-9][0-9])(#|\||\]\])/g, '$1$3–$4 $2$5');

 myContent.value = myContent.value.replace(/[\r\n][\t ]*\+[\t ]*[\r\n][\t ]*\+[\t ]*[\r\n]/g, '\n\n');
 myContent.value = myContent.value.replace(/[\r\n][\t ]*\+[\t ]*[\r\n]/g, '\n');
 if( myContent.value.search(/\|update=complete\|source=[\t ]*[\r\n]\}\}[\t ]*[\r\n](?:\||\{\{col\-break\}\})[\t ]*[\r\n]\{\{#invoke:sports results\|main[\t ]*[\r\n](\|matches_style[^\r\n]*[\r\n])\|team1=[^\r\n]*[\r\n]/g) >=0 ){
 myContent.value = myContent.value.replace(/\|update=complete\|source=[\t ]*[\r\n]\}\}[\t ]*[\r\n](?:\||\{\{col\-break\}\})[\t ]*[\r\n]\{\{#invoke:sports results\|main[\t ]*[\r\n](\|matches_style[^\r\n]*[\r\n])\|team1=[^\r\n]*[\r\n]/g, '\n|show_matches=y\n|short_style=noflag\n$1');
 myContent.value = myContent.value.replace(/\|[ ]*name_[^=]*=[^\r\n]*[\r\n](\|[ ]*match_)/g, '$1');
 }
 
 myContent.value = myContent.value.replace(/<div class="boilerplate metadata plainlinks" id="tfd"[^<>]*>[^<>]*<\/div>[\t\r\n ]*/g, '');
 myContent.value = myContent.value.replace(/<span class="flagicon">\[\[File:[^\[\]]*link=([^\[\]\|]*)\]\]<\/span>/g, '{'+'{flagicon|$1}'+'}');
 
 if(myContent.value.search(/{{#invoke:/g) < 0 && myContent.value.search(/\{\{#if:[ ]*\{\{\{(?:fixtures|expanded)\|\}\}\}/g) >= 0) {
 myContent.value = myContent.value.replace(/\{\{#if:\{\{\{(?:fixtures|expanded)\|\}\}\}\|[ ]*((?:\{\{[^{}]*\}\}|[^\{\}]|[\r\n]\|\}|[\r\n]\{\|)*)\}\}/g, '$1');
 myContent.value = myContent.value.replace(/\{\{!!\}\}/g, '||');
 myContent.value = myContent.value.replace(/\{\{!\}\}/g, '|');
 myContent.value = myContent.value.replace(/\{\{#if:\{\{\{[^{}]*\|\}\}\}[ ]*\|[\t\r\n ]*\}\}/g, '');
 myContent.value = myContent.value.replace(/\{\|[\t ]*[\r\n](?:\|\-[\t ]*[\r\n]|)[\t ]*\|(<!--[^<>]*-->|[\t ])*[\r\n]/g, '');
 myContent.value = myContent.value.replace(/\|(<!--[^<>]*-->|[\t ])*[\r\n]*\{\{#if:[ ]*\{\{\{[ ]*fixtures\|[ ]*\}\}\}[\t ]*\|[\t ]*[\r\n]/g, '');
 myContent.value = myContent.value.replace(/[\r\n]\|\}[\t ]*[\r\n]\}\}[\t ]*[\r\n]\|\}[\t ]*[\r\n]*/g, '\n{' + '{end}' + '}');
 myContent.value = myContent.value.replace(/[\r\n][\t ]*[\r\n]/g, '\n');
 myContent.value = myContent.value.replace(/\{\|[^\r\n]*[\r\n](?:\|\-[\t ]*[\r\n]|)![^\r\n]*Team[^\r\n]*[\r\n]![^\r\n]*Pld[^\r\n]*[\r\n]![^\r\n]*W[^\r\n]*[\r\n]![^\r\n]*D[^\r\n]*[\r\n]![^\r\n]*L[^\r\n]*[\r\n]![^\r\n]*GF[^\r\n]*[\r\n]![^\r\n]*GA[^\r\n]*[\r\n]![^\r\n]*GD[^\r\n]*[\r\n]![^\r\n]*Pts[^\r\n]*[\r\n]/g, '{'+'{fb cl header|nopos=y|noqr=y}'+'}\n');
 myContent.value = myContent.value.replace(/[\r\n]\|[ ]*title[ ]*=[^\r\n\|]*\|[\t ]*\[\[([^\[\]\|]*)\|[ ]*([0-9]+)[ ]*(?:&ndash;|–|\-)[ ]*([0-9]+)[ ]*\]\]/g, '\n{'+'{fb r|gf=$2|ga=$3|ma=$1}'+'}');
 myContent.value = myContent.value.replace(/[\r\n]\|[\t ]*\[\[([^\[\]\|]*)\|[ ]*([0-9]+)[ ]*(?:&ndash;|–|\-)[ ]*([0-9]+)[ ]*\]\]/g, '\n{'+'{fb r|gf=$2|ga=$3|ma=$1}'+'}');
 myContent.value = myContent.value.replace(/[\r\n]\|[\t ]*([0-9]+)[ ]*(?:&ndash;|–|\-)[ ]*([0-9]+)[ ]*/g, '\n{'+'{fb r|gf=$1|ga=$2}'+'}');
 myContent.value = myContent.value.replace(/[\r\n]\|[\t ]*(?:&ndash;|&mdash;|–)/g, '\n{'+'{fb r|r=null}'+'}');
 
 var tc = 0;
 while(myContent.value.search(/\{\{[ ]*fb r2 header(?:\{\{[^{}]*\}\}|[^{}])*\}\}[\t ]*[\r\n]!/g) >=0) {
 tc = tc + 1;
 myContent.value = myContent.value.replace(/(\{\{[ ]*fb r2 header(?:\{\{[^{}]*\}\}|[^{}])*)(\}\})[\t ]*[\r\n]!([^\r\n]*)/g, '$1|$3$2');
 }
 myContent.value = myContent.value.replace(/(\|[ ]*nt[ ]*=[ ]*)0/g, '$1' + tc);
 myContent.value = myContent.value.replace(/(\{\{fb r[^\r\n]*[\r\n])\|\-[^\r\n]*[\r\n][!\|][ ]*style[ ]*=[" ]*text\-align[ ]*:[^\|]*\|([^\r\n]*)/g, '$1{' + '{fb r2 team|t=$2}' + '}');
 myContent.value = '<!-- EXPANDED FIXTURES -->\n' + myContent.value;
 }

 myContent.value = myContent.value.replace(/\[\[MVV\]\]/g, '[[MVV Maastricht|MVV]]');
 myContent.value = myContent.value.replace(/\[\[FC Twente\|(ENS|SC Enschede)\]\]/g, '[[Sportclub Enschede|$1]]');
 myContent.value = myContent.value.replace(/\[\[FC Utrecht\|(DOS)\]\]/g, '[[VV DOS|$1]]');
 myContent.value = myContent.value.replace(/(continentalcup[0-9]+ qualifiers[ ]*=[ ]*)[\r\n]\.\.\.[\t ]*([\r\n])/g, '$1$2');
 myContent.value = myContent.value.replace(/(season[ ]*=[ ]*\[\[)(Division [0-9]+) ([0-9]+)[\-–]([0-9]+)(\]\])/g, '$1$3–$4 Swedish football $2|$3–$4$5');
 myContent.value = myContent.value.replace(/(season[ ]*=[ ]*\[\[)(Division [0-9]+) ([0-9]+)(\]\])/g, '$1$3 Swedish football $2|$3$4');
 myContent.value = myContent.value.replace(/\{\|[ ]*class[ ]*=[" ]*infobox football[^\r\n]*[\r\n](?:\|\-[^\r\n]*[\r\n]|)![^\r\n]*[\r\n](?:\|\-[^\r\n]*[\r\n]|)\|[^\r\n]*[\r\n]'''[^\r\n]*[\r\n]([^\{\}\=]*)[\r\n]\|\}/g, '==See also==\n<!-- FB MARK START -->\n$1\n<!-- FB MARK END -->');
 
 myContent.value = myContent.value.replace(/[\r\n]'''([^\r\n]*)'''[ ]*([\r\n]\{\{fb cl header[^{}]*)/g, '$2|title=$1');
 myContent.value = myContent.value.replace(/\[\[Peru Cup\|Copa Peru\]\]/g, '[[Copa Perú]]');
 myContent.value = myContent.value.replace(/\[\[Peru Cup ([0-9]+)/g, '[[$1 Copa Perú');
 myContent.value = myContent.value.replace(/\[\[Copa Perú\|Peru Cup\]\] ([0-9]+)/g, '$1 [[Copa Perú]]');
 myContent.value = myContent.value.replace(/(\[\[)Campeonato Descentralizado ([0-9]+)/g, '$1$2 Torneo Descentralizado');
 //myContent.value = myContent.value.replace(/[\r\n](![^\|\r\n]*\|[ ]*(?:Pts|Pld|W|D|L|GF|GA|GD))/g, '!$1');
 myContent.value = myContent.value.replace(/\{\|[^\r\n]*[\r\n](?:\|\-[^\r\n]*[\r\n]|)![^r\n]*Team[^\r\n]*Pts[^\r\n]*Pld[^\r\n]*/g, '{'+'{fb cl header|nopos=y|noqr=y|ptsfirst=y}'+'}');
 //myContent.value = myContent.value.replace(/([\r\n]\|[ ]*(?:style[ ]*=[" ]*text-align[ ]*:[ ]*left[;" ]*|align[ ]*=[" ]*left[" ]*)\|)[ ]*([0-9]+\.) /g, '\n|$2$1');
 
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*[Ii]mage[_ ]+label[_ ]*\|[\t ]*x[\t ]*=[\t ]*([0-9]+)[\t ]*\|[\t ]*y[\t ]*=[\t ]*([0-9]+)[\t \|]*text/g, '$1Image label|x=$1subst:#expr:$2/175 round 2}'+'}|y=$1subst:#expr:$3/175 round 2}'+'}|scale=175|text');
 myContent.value = myContent.value.replace(/(\{\{[_ ]*[Ii]mage[_ ]+label(?:\{\{[^{}]*\}\}|[^{}])*)font-size:8[0-9]%[; ]*/g, '$1');
 
 myContent.value = myContent.value.replace(/<!--[ ]*CONVERT[ ]*-->[\t \r\n]*(\{\{[_ ]*[Ll]ocation[_ ]+map)\+/g, '$1 many<!'+'-- CONVERT -->');
 myContent.value = myContent.value.replace(/(<!--[ ]*CONVERT -->)((?:[\r\n]|[^{}])*)/g, '$2$1');
 myContent.value = myContent.value.replace(/[\t ]*\|[\t ]*places[\t ]*=[\t\r\n]*<!--[ ]*CONVERT -->/g, '<!-- CONVERT 1 -->');

 var lt = '';
 var ky = 1;
 while(lt != myContent.value) {
 lt = myContent.value;
 myContent.value = myContent.value.replace(/(\|\{\{subst:#expr:[^{}]*)(\}\}=)([^\r\n]*[\r\n])\|([^\{])/g, '$1$2$3$1+1$2$4');
 var a = myContent.value.match(/\{\{subst:#expr:[ ]*([0-9]+)[ ]*\-[ ]*([0-9]+)[ ]*\}\}/);
 if (a) {
 var ap = Number(a[1]) - Number(a[2]);
 var rexp = new RegExp('\\{\\{subst:#expr:[ ]*' + a[1] + '[ ]*\\-[ ]*' + a[2] + '[ ]*\\}\\}');
 myContent.value = myContent.value.replace(rexp, ap);
 }
 a = myContent.value.match(/\{\{subst:#expr:[ ]*([0-9]+)[ ]*\-[ ]*([23])[ ]*\*[ ]*([0-9]+)[ ]*\-[ ]*([0-9]+)[ ]*\}\}/);
 if (a) {
 var ap = Number(a[1]) - Number(a[2])*Number(a[3]) - Number(a[4]);
 var rexp = new RegExp('\\{\\{subst:#expr:[ ]*' + a[1] + '[ ]*\\-[ ]*' + a[2] + '[ ]*\\*[ ]*' + a[3] + '[ ]*\\-[ ]*' + a[4] + '[ ]*\\}\\}');
 myContent.value = myContent.value.replace(rexp, ap);
 }
 if (mw.config.get('wgNamespaceNumber') === 0) {
 myContent.value = myContent.value.replace(/('''[^'\r\n\{\}]*''')[\t ]*\{\{pad[^{}]*\}\}[\t ]*('''[^'\r\n\{\}]*''')[\t ]*[\r\n]*(\{\{[Cc]ol\-begin)\|width=100%(\}\}[\t ]*[\r\n]*\{\{[Cc]ol\-2\}\}[\t ]*[\r\n]*)(\{\{[Ff]ootball(?:\{\{[^{}]*\}\}|[^{}]|[\r\n])*\}\}[\t ]*[\r\n]*\{\{[Cc]ol\-2\}\}[\t ]*[\r\n]*)/g, '$3$4$1\n$5\n$2');
 myContent.value = myContent.value.replace(/\|[ ]*template_name[ ]*=[\t ]*[\r\n]*[\t ]*(\||\}\})/gi, '$1');
 myContent.value = myContent.value.replace(/\|([ ]*template_name[ ]*)=[ ]*([^\:\[\]\|\{\}\r\n=][^\[\]\|\{\}\r\n=]*?)([\t ]*[\r\n]*[\t ]*)(\||\}\})/g, '{'+'{subst:#ifexist:Template:$2|{'+'{subst:!}'+'}$1{'+'{subst:=}'+'}$2$3}'+'}$4');
 myContent.value = myContent.value.replace(/\{\{\{[^{}\|]+\|((?:\{\{(?:\{\{[^{}]*\}\}|[^{}])*\}\}|[^{}])*)\}\}\}/g, '$1');
 myContent.value = myContent.value.replace(/\{\{#if:[ ]*\|((?:\{\{(?:\{\{[^{}]*\}\}|[^{}])*\}\}|[^{}\|]|\{\{\{[^{}]*\}\}\})*)[\| ]*\}\}/g, '');
 myContent.value = myContent.value.replace(/\{\{#if:[ ]*[a-zA-Z0-9]+[ ]*\|((?:\{\{(?:\{\{[^{}]*\}\}|[^{}])*\}\}|[^{}\|\[\]]|\{\{\{[^{}]*\}\}\})*)(?:|\|(?:(?:\{\{(?:\{\{[^{}]*\}\}|[^{}])*\}\}|[^{}]|\{\{\{[^{}]*\}\}\})*)|)\}\}/g, '$1');
 myContent.value = myContent.value.replace(/\{\{#if:[ ]*\|[ ]*inline[ ]*\|[ ]*inline,title[ ]*\}\}/g, 'inline,title');
 myContent.value = myContent.value.replace(/\{\{[_ ]*[Ii]f[_ ]*empty[_ \|]*\}\}/g, '');
 myContent.value = myContent.value.replace(/\{\{[_ ]*[Ii]f[_ ]*empty[_ \|]*\|[ ]*([^\|{}\[\] ][^\|{}\[\]]*)(?:\|[^{}\[\]]*|)\}\}/g, '$1');
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*[Ss]tr[_ ]+number\/trim[_ ]*\|([^{}]*\}\})/gi, '$1subst:#invoke:String|match|^[%d,%.]*|ignore_errors=true|s=$2');
 myContent.value = myContent.value.replace(/\{\{#invoke:Coordinates\|coordinsert\|(?:\{\{ifempty[\|]*|)(\{\{[Cc]oord[^{}:]*[A-Za-z0-9])[\|]*(\}\})(?:\}\}|)\|(region:[^{}\|]*)\|(type:[^{}\|]*)\}\}/g, '$1|$3_$4$2');
 myContent.value = myContent.value.replace(/\{\{#ifexist:[\t ]*([0-9\-–]+)[\t ]+([^\[\]\|{}]*[^\[\]\|{}\t ])[\t ]*\|[\t ]*\[\[\1 \2\|([^\[\]\|]*)\]\][\t ]*\|[\t ]*\[\[([^\[\]\|]*)\|[^\[\]\|]*\]\][\t ]*\}\}/g, '{'+'{season link|$1|$2|$3|link=$4}'+'}');
 myContent.value = myContent.value.replace(/\{\{#ifexist:[\t ]*([0-9\-–]+)[\t ]+([^\[\]\|{}]*[^\[\]\|{}\t ])[\t ]*\|[\t ]*\[\[\1 \2\|([^\[\]\|]*)\]\][\t ]*\|[\t ]*\[\[\2\]\][\t ]*\}\}/g, '{'+'{season link|$1|$2}'+'}');
 myContent.value = myContent.value.replace(/(\{\{season link\|[^{}\|]*\|)([^{}\|]*)(\|[^{}]*)\|link=\2(\}\})/g, '$1$2$3$4');
 
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*(#if:|#ifeq:|#switch:|[Ii]f[_ ]*empty|#property:|delink|[Ll][Cc][ ]*:|PAGENAME)/gi, '$1subst:$2');
 
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*([Cc]ompactTable)/g, '$1subst:$2|');
 myContent.value = myContent.value.replace(/(of[ ]+)([0-9,\.]+)(?: | )*km²/gi, '$1{'+'{cvt|$2|km2}'+'}');
 myContent.value = myContent.value.replace(/([a-z][ ]+)([0-9,\.]+)(?: | )*km<sup>2<\/sup>/gi, '$1{'+'{cvt|$2|km2}'+'}');
 //myContent.value = myContent.value.replace(/(\[\[[^\[\]]*)(km)/gi, '$1<!-- RM THIS -->$2');
 //myContent.value = myContent.value.replace(/([a-z][ ]+)([0-9,\.]+)(?: | )*km([ ]*[a-z\.])/gi, '$1{'+'{cvt|$2|km}'+'}$3');
 //myContent.value = myContent.value.replace(/<!-- RM THIS -->/g, '');
 myContent.value = myContent.value.replace(/\{\{\{(?:religion[0-9]*|ethnicity[0-9]*|other_date[0-9]*_title)\}\}\}/g, '');
 myContent.value = myContent.value.replace(/(\|[ ]*population_total[ ]*=[ ]*[0-9,]+)\./g, '$1');
 myContent.value = myContent.value.replace(/(\|[ ]*population_total[ ]*=[ ]*[0-9,]+)\./g, '$1');
 myContent.value = myContent.value.replace(/(\|[ ]*population_total[ ]*=[ ]*[0-9,]+)[ ]*\(([^\(\)\r\n]*)\)[ ]*([\r\n]\|[ ]*population_as_of[ ]*=)[ ]*/g, '$1$3 $2');
 myContent.value = myContent.value.replace(/\|[ ]*demographics_type([12])[ ]*=[\t\r\n ]*\|[ ]*demographics\1_footnotes[ ]*=[\t\r\n ]*(\|)/g, '$2');
 myContent.value = myContent.value.replace(/\|[ ]*demographics([12])_title([0-9]*)[ ]*=[\t\r\n ]*\|[ ]*demographics\1_info\2[ ]*=[\t\r\n ]*(\|)/g, '$3');
 myContent.value = myContent.value.replace(/\|[ ]*demographics([12])_title([0-9]*)[ ]*=[\t\r\n ]*\|[ ]*demographics\1_info\2[ ]*=[\t\r\n ]*(\|)/g, '$3');
 myContent.value = myContent.value.replace(/\|[ ]*(?:area_total_sq_mi|elevation_(?:max_|min_)ft|elevation_ft|population_density_sq_mi)[ ]*=[\t\r\n ]*(\|)/g, '$1');
 myContent.value = myContent.value.replace(/\|[ ]*(?:area_total_sq_mi|elevation_(?:max_|min_)ft|elevation_ft|population_density_sq_mi)[ ]*=[\t\r\n ]*[\r\n](<!--[^\r\n]*[\r\n]\|)/g, '$1');
 myContent.value = myContent.value.replace(/\|[ ]*(?:area_land_sq_mi|area_water_sq_mi)[ ]*=[\t\r\n ]*(\|)/g, '$1');
 myContent.value = myContent.value.replace(/\|[ ]*established_title([3-9])[ ]*=[\t\r\n ]*\|[ ]*established_date\1[ ]*=[\t\r\n ]*(\|)/g, '$2');
 myContent.value = myContent.value.replace(/(\|[ ]*population_density_km2[\t ]*=[\t ]*)\{\{[^{}]*\{\{[^{}]*\{\{[^{}]*\}\}[^{}]*\}\}[^{}]*\}\}[\t ]*([\r\n])/g, '$1auto$2');
 myContent.value = myContent.value.replace(/<ul>[\t\r\n ]*<li>[\t\r\n ]*<\/li>[\t\r\n ]*<\/ul>/g, '')
 myContent.value = myContent.value.replace(/(\|[ ]*p[0-9]+[ ]*=[ ]*)<ul>[\t\r\n ]*<li>([^<>\r\n]*)<\/li>[\t\r\n ]*<\/ul>/g, '$1$2')
 myContent.value = myContent.value.replace(/\|[ ]*p(?:[3-9]|[1-9][0-9]+)[ ]*=[ ]*[\r\n]/g, '');
 }
 myContent.value = myContent.value.replace(/(\{\{(?:One|Two)Leg)([^\r\n]*[\r\n])\|\-[\t ]*[\r\n]\|align=right\|/, '$1$2$1Result|');
 myContent.value = myContent.value.replace(/([\r\n][!\|])[ ]*<div[ ]*style[ ]*=[" ]*text\-align[ ]*:[ ]*center[; "]*>([^\r\n]*)<\/div>[ ]*([\r\n])/g, '$1 style="text-align:center"| $2$3');
 myContent.value = myContent.value.replace(/([\r\n][!\|][ ]*[rc]o[lw]span[ ]*=[ "']*[0-9]+[ "']*)\|[ ]*<div[ ]*style[ ]*=[" ]*text\-align[ ]*:[ ]*center[; "]*>([^\r\n]*)<\/div>[ ]*([\r\n])/g, '$1 style="text-align:center"| $2$3');
 myContent.value = myContent.value.replace(/(<!-- FB MARK START -->)[\t ]*[\r\n]*(\[\[[^\r\n]*\))[\t ]*('')[\t ]*<br>[\t ]*([\r\n])/g, '*$2$3$4$1');
 myContent.value = myContent.value.replace(/(<!-- FB MARK START -->)[\t ]*[\r\n]*(\[\[[^\r\n]*\]\])[\t ]*<br>[\t ]*([\r\n])/g, '*$2$3$1');
 myContent.value = myContent.value.replace(/(<!-- FB MARK START -->)[\t ]*[\r\n]*\|\-[^\r\n]*/g, '$1');
 myContent.value = myContent.value.replace(/(<!-- FB MARK START -->)[\t ]*[\r\n]*<!-- FB MARK END -->/g, '');

 myContent.value = myContent.value.replace(/([\r\n]![^\r\n]*?)'''/g, '$1');
 myContent.value = myContent.value.replace(/([\r\n]![^\r\n]*[\r\n][^\|!\{][^\r\n]*?)'''/g, '$1');

 myContent.value = myContent.value.replace(/class="wikitable" style="[ ]*/g, 'class="wikitable" style="');
 var r = new RegExp('<!--[ ]*CONVERT ' + ky + ' -->[\\t\\r\\n ]*\\{\\{[_ ]*[Ll]ocation[_ ]*map~[_ ]*(\|(?:[^{}]|\\{\\{[^{}]*\\}\\}|[\\r\\n])*)\\}\\}', 'g');
 myContent.value = myContent.value.replace(r, '\n<!-- CNUM'+ky+' -->$1<!-- CONVERT ' + (ky+1) + ' -->');
 myContent.value = myContent.value.replace(/<!--[ ]*CONVERT [0-9]+ -->[\t ]*([\r\n]*[\t ]*\}\})/g, '$1');
 myContent.value = myContent.value.replace(/(<!-- CNUM)([0-9]+)( -->)\|(?:[ ]*1[ ]*=|)[^={}]*(\|[ ]*[a-z_]+)([ ]*=)/g, '$4$2$1$3$5');
 myContent.value = myContent.value.replace(/(<!-- CNUM)([0-9]+)( -->)(\|[ ]*[a-z_]+)([ ]*=)/g, '$4$2$1$3$5');
 myContent.value = myContent.value.replace(/(\|[ ]*[a-z_]+)([0-9]+)<!-- CNUM -->([ ]*=(?:\[\[[^\[\]]*\]\]|\{\{[^{}]*\}\}|[^\{\}\|\[\]])*\|[ ]*[a-z_]+)([ ]*=)/g, '$1$2$3$2<!-- CNUM -->$4');
 myContent.value = myContent.value.replace(/(\|[ ]*[a-z_]+[0-9]+<!-- CNUM -->[ ]*=(?:\[\[[^\[\]]*\]\]|\{\{[^{}]*\}\}|[^\{\}\|\[\]])*)\|(?:[ ]*1[ ]*=|)[^={}\r\n]*([\r\n\t ]*\||[\r\n\t ]*\}\})/g, '$1$2');
 myContent.value = myContent.value.replace(/(\|[ ]*[a-z_]+[0-9]+)<!-- CNUM -->([ ]*=(?:\[\[[^\[\]]*\]\]|\{\{[^{}]*\}\}|[^\{\}\|\[\]])*)([\r\n\t ]*\|[ ]*[a-z_]+[0-9]+[ ]*=|[\r\n\t ]*\}\})/g, '$1$2$3');
 ky = ky + 1;
 }
 myContent.value = myContent.value.replace(/(\|[ ]*(?:lat|lon))(_(?:deg|min|sec|dir))([0-9]+)([ ]*=)/g, '$1$3$2$4');
 myContent.value = myContent.value.replace(/(\|[ ]*(?:label|mark))(_?size)([0-9]+)([ ]*=)/g, '$1$3$2$4');
 myContent.value = myContent.value.replace(/([Ii]nfobox)[_ ]+Bridge/g, '$1 bridge');
 myContent.value = myContent.value.replace(/\|[\t ]*(?:lat|long|map_text|map_cue)[\t ]*=[\t ]*[\r\n]/g, '');
 myContent.value = myContent.value.replace(/(\{\{[Ll]ocation[_ ]+map)\+([^{}]*)\|[ ]*places[ ]*=[\t\r\n ]*\{\{[Ll]ocation[_ ]+map\~[\t \r\n]*\|[^{}\|\r\n]*(\|[^{}]*)\}\}([^{}]*\}\})/g, '$1$2$3$4');
 myContent.value = myContent.value.replace(/(\|[ ]*)extra[ ]*(=[ ]*)[\r\n ]*(\{\{[Ll]ocation map)/g, '$1map_caption $2$3<'+'!-- EXTRA -->');
 myContent.value = myContent.value.replace(/(<!--[ ]* EXTRA -->)[\r\n ]*\|[\r\n ]*/g, '|$1');
 myContent.value = myContent.value.replace(/(<!--[ ]* EXTRA -->)([^\r\n\|\{\}]*)/g, '$2$1');
 myContent.value = myContent.value.replace(/(<!--[ ]* EXTRA -->)([\r\n]?[\t ]*\|[\t ]*)([A-Za-z0-9_])/g, '$2border = infobox$2float = center$1$2$3');

 for (var kk=0; kk<20; kk++) {
 while(myContent.value.search(/(<!--[ ]* EXTRA -->)[\r\n]?[\t ]*\|[\t ]*[A-Za-z0-9_]+[\t ]*=[\t ]*([\r\n]?[\t ]*(?:\||\}\}))/g, '$1$2') >=0 ) {
 myContent.value = myContent.value.replace(/(<!--[ ]* EXTRA -->)[\r\n]?[\t ]*\|[\t ]*[A-Za-z0-9_]+[\t ]*=[\t ]*([\r\n]?[\t ]*(?:\||\}\}))/g, '$1$2');
 }
 myContent.value = myContent.value.replace(/(<!--[ ]* EXTRA -->)[\r\n]?[\t ]*\|[\t ]*(?:float|border)[\t ]*=[a-z\t ]*([\r\n]?[\t ]*(?:\||\}\}))/g, '$1$2');
 myContent.value = myContent.value.replace(/(<!--[ ]* EXTRA -->)([\r\n]?[\t ]*\|[\t ]*(?:relief|label|caption|mark|width|position|lat|long|background|(?:lat|lon)_(?:deg|min|sec|dir))[\t ]*=(?:\{\{[^{}]*\}\}|\[\[[^\[\]]*\]\]|[^\r\n\|\[\]\{\}])*)([\r\n]?[\t ]*(?:\||\}\}))/g, '$2$1$3');
 }
 myContent.value = myContent.value.replace(/<!--[ ]* EXTRA -->[\t \r\n]*(\}\})/g, '$1');
 myContent.value = myContent.value.replace(/(\{\{[Ll]ocation map\|USA )([^\r\n]*)([\r\n][^{}]*\|[ ]*caption[ ]*=[ ]*)<!-- blank -->[\t ]*[\r\n]*(\}\})/g, '$1$2$3Location in $2\n$4');
 myContent.value = myContent.value.replace(/(\{\{[Ll]ocation map\|)([^\r\n]*)([\r\n][^{}]*\|[ ]*caption[ ]*=[ ]*)<!-- blank -->[\t ]*[\r\n]*(\}\})/g, '$1$2$3Location in $2\n$4');
 myContent.value = myContent.value.replace(/(\|[ ]*(?:width|label|caption)[ ]*=)/g, '‽$1');
 myContent.value = myContent.value.replace(/(\|[\t ]*map_locator[\t ]*=)[\t\r\n ]*(\{\{)/g, '$1 $2');
 while(myContent.value.search(/\|[\t ]*map_locator[\t ]*=[\t ]*\{\{[_ ]*[Ll]ocation[_ ]+map(?:\{\{[^{}]*\}\}|[^{}\r\n])*[\r\n]/g) >= 0) {
 myContent.value = myContent.value.replace(/(\|[\t ]*map_locator[\t ]*=[\t ]*\{\{[_ ]*[Ll]ocation[_ ]+map(?:\{\{[^{}]*\}\}|[^{}\r\n])*)[\r\n]/g, '$1 ');
 }
 for (var jj=0; jj<3; jj++) {
 myContent.value = myContent.value.replace(/(\|[ ]*)(map_locator[ ]*=[ \r\n]*\{\{[_ ]*[Ll]ocation[_ ]+map[_ ]*\|(?:\{\{[^{}]*\}\}|[^\{\}])*)‽\|[ ]*width[ ]*=[ ]*(‽?\||\}\})/g, '$1$2$3');
 myContent.value = myContent.value.replace(/(\|[ ]*)(map_locator[ ]*=[ \r\n]*\{\{[_ ]*[Ll]ocation[_ ]+map[_ ]*\|(?:\{\{[^{}]*\}\}|[^\{\}])*)‽\|[ ]*width[ ]*=[ ]*([0-9]+)[ ]*(‽?\||\}\})/g, '$1map_size = $3\n$1$2$4');
 myContent.value = myContent.value.replace(/(\|[ ]*)(map_locator[ ]*=[ \r\n]*\{\{[_ ]*[Ll]ocation[_ ]+map[_ ]*\|(?:\{\{[^{}]*\}\}|[^\{\}])*)‽\|[ ]*label[ ]*=[ ]*(‽?\||\}\})/g, '$1$2$3');
 myContent.value = myContent.value.replace(/(\|[ ]*)(map_locator[ ]*=[ \r\n]*\{\{[_ ]*[Ll]ocation[_ ]+map[_ ]*\|(?:\{\{[^{}]*\}\}|[^\{\}])*)‽\|[ ]*label[ ]*=[ ]*((?:\{\{[^{}]*\}\}|\[\[[^\[\]]*\]\]|[^\{\}\|\[\]‽])*)(‽?\||\}\})/g, '$1map_dot_label = $3\n$1$2$4');
 myContent.value = myContent.value.replace(/(\|[ ]*)(map_locator[ ]*=[ \r\n]*\{\{[_ ]*[Ll]ocation[_ ]+map[_ ]*\|(?:\{\{[^{}]*\}\}|[^\{\}])*)‽\|[ ]*caption[ ]*=[ ]*((?:\{\{[^{}]*\}\}|\[\[[^\[\]]*\]\]|[^\{\}\|\[\]‽])*)(‽?\||\}\})/g, '$1map_caption = $3\n$1$2$4');
 }
 myContent.value = myContent.value.replace(/‽(\|[ ]*(?:width|label|caption)[ ]*=)/g, '$1');
 myContent.value = myContent.value.replace(/(\|[ ]*)map_locator[ ]*=[ \r\n]*\{\{[_ ]*[Ll]ocation[_ ]+map[_ ]*\|[ ]*([^\|\{\}\[\]]*)[ ]*\|(?:\{\{[^{}]*\}\}|[^\{\}])*\}\}/g, '$1map_type = $2');
 myContent.value = myContent.value.replace(/(\|[ ]*(?:map_caption|map_size|map_dot_label)[ ]*=[^\r\n]*[\r\n])(\|[ ]*(?:map_type)[ ]*=[^\r\n]*[\r\n])/g, '$2$1');
 myContent.value = myContent.value.replace(/(\|[ ]*(?:map_caption|map_size)[ ]*=[^\r\n]*[\r\n])(\|[ ]*(?:map_type|map_dot_label)[ ]*=[^\r\n]*[\r\n])/g, '$2$1');
 myContent.value = myContent.value.replace(/(\|[ ]*(?:map_caption)[ ]*=[^\r\n]*[\r\n])(\|[ ]*(?:map_type|map_size|map_dot_label)[ ]*=[^\r\n]*[\r\n])/g, '$2$1');
 
 myContent.value = myContent.value.replace(/(\[\[[^\[\]\|]*\|)(\{\{(?:[Ss]C|[Aa]ut|[Ss]caps|[Ss]mall\-caps|[Ss]m|[Ss]mall[_ ]+caps|[Ss]c1|[Ss]mall[_ ]+Caps|[Vv]ersalita|[Ss]mallcaps)\|)([^{}\|]*)(\}\})(\]\])/g, '$2$1$3$5$4');
 if (myContent.value.search(/(\{\{)[_ ]*(?:[Uu]nit[_ ]+weight|[Gg]eobox2[_ ]+unit\/weight)[_ ]*/g) >= 0) {
 myContent.value = myContent.value.replace(/([Ii]nfobox)[_ ]+Rugby/g, '$1 rugby');
 myContent.value = myContent.value.replace(/(?:[\t ]|<[\/\t ]*[Bb][r][\/\t ]*>|[\r\n])*(\{\{[Aa]uthority[\t _]+control)/g, '\n$1');
 myContent.value = myContent.value.replace(/([\r\n](?:\*[^\r\n]*|\{\{[Rr]eflist\}\})[\r\n])(\{\{[Aa]uthority[\t _]+control)/g, '$1\n$2');
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*[Gg]eobox2[_ ]+unit\/weight[_ ]*/g, '$1unit weight');
 if(myContent.value.search(/[Rr]ugby/g) >=0) {
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*[Uu]nit weight[_ ]*\|[ ]*kg[ ]*\|[ ]*([0-9\.]+)[ ]*(\}\})/g, '$1cvt|$2|kg|lb stlb$3');
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*[Uu]nit weight[_ ]*\|[ ]*lb[ ]*\|[ ]*([0-9\.]+)[ ]*(\}\})/g, '$1cvt|$2|lb|kg stlb$3');
 }
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*[Uu]nit weight[_ ]*\|[ ]*lb[ ]*\|[ ]*([0-9\.]+)[ ]*(\}\})/g, '$1cvt|$2|lb$3');
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*[Uu]nit weight[_ ]*\|[ ]*kg[ ]*\|[ ]*([0-9\.]+)[ ]*(\}\})/g, '$1cvt|$2|kg$3');
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*([Uu]nit weight)/g, '$1subst:$2');
 var editsummary = document.getElementsByName('wpSummary')[0];
 editsummary.value = 'replace deprecated unit template';
 document.forms.editform.wpDiff.click();
 }
 
 // stub spacing
 myContent.value = myContent.value.replace(/([\r\n])[\t ]*(\{\{[^{}]*\-stub[\t ]*\}\})[\t ]*/g, '$1‽$2‽');
 myContent.value = myContent.value.replace(/(\})‽(?:[\t ]|[\r\n])*‽(\{)/g, '$1\n$2');
 myContent.value = myContent.value.replace(/(\})‽/g, '$1');
 myContent.value = myContent.value.replace(/(?:[\t ]|[\r\n])*‽(\{)/g, '\n\n\n$1');
 myContent.value = myContent.value.replace(/\{\{(?:[Cc]lear|\-)\}\}(?:[\t ]|[\r\n])*([\r\n]==[ ]*[^=]*==(?:[\t ]|[\r\n])*)(\{\{)([Pp]ortal\|[^{}]*)(\}\})/g, '$1$2stack|$2$3$4$4');
 while (myContent.value.search(/(<hr>)[ ]*(\[\[Template:[^\|\[\] ]*) /g) >= 0) {
 myContent.value = myContent.value.replace(/(<hr>)[ ]*(\[\[Template:[^\|\[\] ]*) /, '$1$2_');
 } 
 myContent.value = myContent.value.replace(/(<hr>)[ ]*\[\[(Template:Fb_team[^\|]*)\|([^\[\]]*)\]\]/g, '$1[//en.wikipedia.org/w/index.php?|name=$2 $3]');

 myContent.value = myContent.value.replace(/[\t ]*[\r\n]*[\t ]*[\r\n]*[\t ]*[\r\n]*__NOTOC__[\t ]*[\r\n]*[\t ]*[\r\n]*\{\|[\t ]*class[ ]*=[" ]*wikitable[^\r\n]*[^{}]*List of shipwrecks[^{}]*\|\}[\t ]*[\r\n]*[\t ]*[\r\n]*/g, '\n{'+'{Calendar ToC}'+'}\n');
 myContent.value = myContent.value.replace(/1([7-9]) Football League (One|Two) table/g, '1$1 EFL League $2 table');
 myContent.value = myContent.value.replace(/1([7-9]) EFL (One|Two) table/g, '1$1 EFL League $2 table');
 myContent.value = myContent.value.replace(/[\t ]*[\r\n]*[\t ]*[\r\n]*(\{\{)[_ ]*((?:19[0-9][0-9]|200[0-9]|201[0-8]))[\-–]((?:2000|[0-9][0-9])[_ ]+(?:FA[_ ]+|)Premier[_ ]+League)[_ ]+table([^{}]*\}\})[\t ]*[\r\n]*[\t ]*[\r\n]*/g, '\n$1:$2–$3$4\n');
 myContent.value = myContent.value.replace(/[\t ]*[\r\n]*[\t ]*[\r\n]*(\{\{)[_ ]*((?:19[0-9][0-9]|200[0-9]|201[0-8]))[\-–]((?:2000|[0-9][0-9])[_ ]+(?:EFL|Football)[_ ]+League[_ ]+(?:One|Two))[_ ]+table([^{}]*\}\})[\t ]*[\r\n]*[\t ]*[\r\n]*/g, '\n$1:$2–$3$4\n');
 // myContent.value = myContent.value.replace(/<[\t ]*Div[^<>]*NavFrame[^<>]*>[\t \r\n]*<[\t ]*Div[^<>]*NavHead[^<>]*>((?:[^<>]|<\/ref>|<[\t ]*ref[^<>]*>)*)<\/Div>[\t \r\n]*<Div[^<>]*>/gi, '\{\{Ahnentafel top|$1\}\}');
 myContent.value = myContent.value.replace(/[\t ]*[\r\n]*\{\{[_ ]*[Ff]b[_ ]+match[_ ]+header[_ ]*\}\}[\t ]*[\r\n]*[\t ]*[\r\n]*/g, '\n');
 //myContent.value = myContent.value.replace(/[\t ]*[\r\n]*[\t ]*([\r\n]\{\{)[_ ]*([Ff]b[_ ]+match2?)[_ \r\n]*(\|)/g, '$1subst:$2/sandbox$3');
 myContent.value = myContent.value.replace(/[\t ]*[\r\n]*[\t ]*([\r\n]\{\{)[_ ]*([Ff]b[_ ]+match[_ ]+footer)/g, '$1subst:$2/sandbox');
 if (mw.config.get('wgNamespaceNumber') === 0) {
 myContent.value = myContent.value.replace(/[\t\( ]*\[\[[^\[\]\|]*[Aa]ssociation[_ ]*[Ff]ootball[^\[\]\|]*\|a\.e\.t\.?\]\][\t\) ]*/g, ' {' + '{aet}' + '}');
 myContent.value = myContent.value.replace(/\|[ ]*tname[ ]*=[^\|\r\n\{\}]*/g, '');
 }
 myContent.value = myContent.value.replace(/(\{\{subst:[Ff]b[_ ]+match2?(?:[\r\n]|[^{}])*)\{\{aet\}\}/g, '$1{'+'{subst:!}'+'}aet=y');
 myContent.value = myContent.value.replace(/(\|[ ]*bg[ ]*=[ ]*)[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][\t ;]*;[\t ]*background[\t ]*:[\t ]*#([A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9])[; ]*([\r\n])/g, '$1$2$3');
 if ((myContent.value.search(/<(?:)!--[ ]*CONVERT[ ]*LM[ ]*-->/gi) >= 0)) {
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*([Ll]ocation[_ ]+map)\+/g, '$1$2 many');
 var k = 1;
 while (myContent.value.search(/\{\{[_ ]*[Ll]ocation[_ ]+map\~[_ ]*\|[^\|\{\}\[\]=]*\|(?:[^\{\}]|\{\{[^\{\}]*\}\})*\}\}/g) >=0 ) {
 myContent.value = myContent.value.replace(/\{\{[_ ]*[Ll]ocation[_ ]+map\~[_ ]*\|[^\|\{\}\[\]=]*(\|(?:[^\{\}]|\{\{[^\{\}]*\}\})*)\}\}/, '<'+'!-- LM ' + k + ' -->$1');
 k = k + 1;
 }
 for (k=0; k<10; k++) {
 myContent.value = myContent.value.replace(/(<(?:)!-- LM )([0-9]+)( -->)([ ]*\|[^=\[\]\{\}0-9]*[^=\[\]\{\}0-9 ])([ ]*=(?:[^\[\]\{\}\|]|\[\[[^\[\]]*\]\]|\{\{[^{}]*\}\})*)/g, '$4$2$5$1$2$3');
 }
 myContent.value = myContent.value.replace(/(mark|label)(_?size)([0-9]+)/g, '$1$3$2');
 myContent.value = myContent.value.replace(/(lat|lon)(_deg|_min|_sec|_dir)([0-9]+)/g, '$1$3$2');
 myContent.value = myContent.value.replace(/\|[ ]*lat([0-9]+)_deg[ ]*=[ ]*(\-?[0-9\.]+)[ ]*\|[ ]*lon\1_deg[ ]*=[ ]*(\-?[0-9\.]+)/g, '|coordinates$1={' + '{coord|$2|$3}' + '}');
 myContent.value = myContent.value.replace(/\|[ ]*lat([0-9]+)_deg[ ]*=[ ]*([0-9]+)[ ]*\|[ ]*lat\1_min[ ]*=[ ]*([0-9\.]+)[ ]*\|[ ]*lon\1_deg[ ]*=[ ]*([0-9]+)[ ]*\|[ ]*lon\1_min[ ]*=[ ]*([0-9\.]+)/g, '|coordinates$1={' + '{coord|$2|$3|N|$4|$5|E}' + '}');
 myContent.value = myContent.value.replace(/\|[ ]*lat([0-9]+)_deg[ ]*=[ ]*([0-9]+)[ ]*\|[ ]*lat\1_min[ ]*=[ ]*([0-9\.]+)[ ]*\|[ ]*lat\1_dir[ ]*=[ ]*([NS])[ ]*\|[ ]*lon\1_deg[ ]*=[ ]*([0-9]+)[ ]*\|[ ]*lon\1_min[ ]*=[ ]*([0-9\.]+)[ ]*\|[ ]*lon\1_dir[ ]*=[ ]*([EW])/g, '|coordinates$1={' + '{coord|$2|$3|$4|$5|$6|$7}' + '}');
 myContent.value = myContent.value.replace(/\|[ ]*lat([0-9]+)_deg[ ]*=[ ]*([0-9]+)[ ]*\|[ ]*lat\1_min[ ]*=[ ]*([0-9]+)[ ]*\|[ ]*lat\1_sec[ ]*=[ ]*([0-9\.]+)[ ]*\|[ ]*lat\1_dir[ ]*=[ ]*([NS])[ ]*\|[ ]*lon\1_deg[ ]*=[ ]*([0-9]+)[ ]*\|[ ]*lon\1_min[ ]*=[ ]*([0-9]+)[ ]*\|[ ]*lon\1_sec[ ]*=[ ]*([0-9\.]+)[ ]*\|[ ]*lon\1_dir[ ]*=[ ]*([EW])/g, '|coordinates$1={' + '{coord|$2|$3|$4|$5|$6|$7|$8|$9}' + '}');
 myContent.value = myContent.value.replace(/\|[ ]*places[ ]*=[ ]*/g, '');
 myContent.value = myContent.value.replace(/<(?:)!-- LM [0-9]+[ ]*-->/g, '');
 myContent.value = myContent.value.replace(/<(?:)!--[ ]*CONVERT[ ]*LM[ ]*-->/, '');
 }
 myContent.value = myContent.value.replace(/(\{\{)[_ ]*NHLTeamSeason/g, '$1Infobox ice hockey team season');
 if (config.wgNamespaceNumber === 0) {
 myContent.value = myContent.value.replace(/([\r\n][!\|][^\|\r\n]*style[ ]*=[ ]*"[^"]*)("[^\|\r\n]*\|[ ]*\{\{[_ ]*[Tt]?[Nn]avbar[^{}]*)\|[ ]*fontcolor[ ]*=[ ]*([^{}\|]*)/g, '$1;color:$3;$2');
 myContent.value = myContent.value.replace(/(\{\{[_ ]*[Tt]?[Nn]avbar[^{}]*)\|[ ]*(?:mini|plain)[ ]*=[^\|\{\}]*/g, '$1');
 myContent.value = myContent.value.replace(/[\r\n][\t ]*\{\{[_ ]*[Tt]?[Nn]avbar[^{}\|]*\|[\t ]*\|[^{}=]*\}\}[\t ]*([\r\n])/g, '$1');
 myContent.value = myContent.value.replace(/([\r\n][!\|][^\|\r\n]*style[ ]*=[ ]*"[^"]*)("[^\|\r\n]*\|)[\t ]*\{\{[_ ]*[Tt]?[Nn]avbar[^{}\|]*\|([^{}\|=]*)\|[^{}\|=]*\}\}/g, '$1;text-align:center;$2 $3');
 myContent.value = myContent.value.replace(/\{\{[_ ]*[Tt]?[Nn]avbar[^{}\|]*\|([^{}\|=]*)\|[^{}\|=]*\}\}/g, '$1');
 myContent.value = myContent.value.replace(/(style[ ]*=[ ]*"[^"\r\n]*;)[\t ]*;/g, '$1');
 myContent.value = myContent.value.replace(/(style[ ]*=[ ]*"[^"\r\n]*;)[\t ]*;/g, '$1');
 myContent.value = myContent.value.replace(/(style[ ]*=[ ]*"[^"\r\n]*;)[\t ]*;/g, '$1');
 myContent.value = myContent.value.replace(/(style[ ]*=[ ]*"[^"\r\n]*);[ ]*text\-align[ ]*:[ ]*center[ ]*(;[^"\r\n]*text\-align[ ]*:[ ]*center)/g, '$1$2');
 myContent.value = myContent.value.replace(/(style[ ]*=[ ]*"[^"\r\n]*);[ ]*color[ ]*:[^;"\r\n]*((?:;[^"\r\n]*;|;)[\t ]*color[ ]*:)/g, '$1$2');
 
 myContent.value = myContent.value.replace(/[\t ]+(\/)/g, ' $1');
 myContent.value = myContent.value.replace(/[\t ]+(\/[A-Z0-9][A-Z0-9])/g, '$1');
 myContent.value = myContent.value.replace(/\|[ ]*legendorder[ ]*=[ ]*A\/H\/W\/D\/L[\t ]*[\r\n]/, '');
 
 myContent.value = myContent.value.replace(/([\t ]*[\r\n])[\t ]*([\r\n][\t ]*[\r\n]\{\{[^{}]*stub[\t ]*\}\})/g, '$1<'+'!--AUTOCLEAN-->$2');
 myContent.value = myContent.value.replace(/([\r\n])([\t ]*(?:id|bar|width|from|barset):)/g, '$1<'+'!--AUTOCLEAN-->$2');
 myContent.value = myContent.value.replace(/([\t ]*[\r\n])[\t ]*([\r\n])[\t ]*[\r\n]*[\t ]*[\r\n]*/g, '$1$2');
 myContent.value = myContent.value.replace(/<(?:)!--AUTOCLEAN-->/g, '');
 }

 if (myContent.value.search(/[Ii]nfobox[_ ]*[Ss]ettlement/gi) >= 0) {
 myContent.value = myContent.value.replace(/(<!--[^<>]*basic info[^<>]*-->)[\t ]*(\|)/gi, '$1\n$2');
 myContent.value = myContent.value.replace(/ (<!--[\-\t ]*(?:images |location |politics |area |population|general info)[^<>]*-->)/gi, ' \n$1');
 myContent.value = myContent.value.replace(/[\t ]*\|[\t ]*(?:imagesize|blank_emblem_size|mapsize)[\t ]*=[\t ]*[\r\n]/g, '');
 myContent.value = myContent.value.replace(/[\t ]*\|[\t ]*blank_name_sec1[\t ]*=[\t ]*[\r\n][\t ]*\|[\t ]*blank_info_sec1[\t ]*=[\t ]*[\r\n]/g, '');
 myContent.value = myContent.value.replace(/[\t ]*\|[\t ]*image_blank_emblem[\t ]*=[\t ]*[\r\n][\t ]*\|[\t ]*blank_emblem_type[\t ]*=[\t ]*[\r\n]/g, '');
 myContent.value = myContent.value.replace(/[\t ]*\|[\t ]*translit_lang([0-9]*)[\t ]*=[\t ]*[\r\n][\t ]*\|[\t ]*translit_lang\1_type[\t ]*=[\t ]*[\r\n]\|[\t ]*translit_lang\1_info[\t ]*=[\t ]*[\r\n]/g, '');
 myContent.value = myContent.value.replace(/[\t ]*\|[\t ]*translit_lang([0-9]*)_type([0-9]*)[\t ]*=[\t ]*[\r\n]\|[\t ]*translit_lang\1_info\2[\t ]*=[\t ]*[\r\n]/g, '');
 myContent.value = myContent.value.replace(/[\t ]*\|[\t ]*seat1_type[\t ]*=[\t ]*Largest city[\t ]*[\r\n][\t ]*\|[\t ]*seat1[\t ]*=[\t ]*[\r\n]/g, '');
 myContent.value = myContent.value.replace(/[\t ]*\|[\t ]*subdivision_type([3-9])[\t ]*=[\t ]*[\r\n][\t ]*\|[\t ]*subdivision_name\1[\t ]*=[\t ]*[\r\n]/g, '');
 myContent.value = myContent.value.replace(/[\t ]*\|[\t ]*leader_title([2-9])[\t ]*=[\t ]*[\r\n][\t ]*\|[\t ]*leader_name\1[\t ]*=[\t ]*[\r\n]/g, '');
 myContent.value = myContent.value.replace(/[\t ]*\|[\t ]*city_logo[\t ]*=[\t ]*[\r\n][\t ]*\|[\t ]*citylogo_size[\t ]*=[\t ]*[\r\n]/g, '');
 myContent.value = myContent.value.replace(/[\t ]*\|[\t ]*dot_x[\t ]*=[\t ]*[\r\n]*[\t ]*\|[\t ]*dot_y[\t ]*=[\t ]*[\r\n]/g, '');
 myContent.value = myContent.value.replace(/[\t ]*\|[\t ]*image_dot_map[\t ]*=[\t ]*[\r\n][\t ]*\|[\t ]*dot_mapsize[\t ]*=[\t ]*[\r\n][\t ]*\|[\t ]*dot_map_caption[\t ]*=[\t ]*[\r\n]/g, '');
 myContent.value = myContent.value.replace(/[\t ]*\|[\t ]*image_map1[\t ]*=[\t ]*[\r\n][\t ]*\|[\t ]*mapsize1[\t ]*=[\t ]*[\r\n][\t ]*\|[\t ]*map_caption1[\t ]*=[\t ]*[\r\n]/g, '');
 myContent.value = myContent.value.replace(/[\t ]*\|[\t ]*population_blank([1-9])_title[\t ]*=[\t ]*[\r\n][\t ]*\|[\t ]*population_blank\1[\t ]*=[\t ]*[\r\n]/g, '');
 myContent.value = myContent.value.replace(/[\t ]*\|[\t ]*population_density_blank([1-9])_km2[\t ]*=[\t ]*[\r\n]/g, '');
 myContent.value = myContent.value.replace(/[\t ]*\|[\t ]*population_density_blank([1-9])_sq_?mi[\t ]*=[\t ]*[\r\n]/g, '');
 myContent.value = myContent.value.replace(/[\t ]*\|[\t ]*blank([1-9]?)_name[\t ]*=[\t ]*[\r\n][\t ]*\|[\t ]*blank\1_info[\t ]*=[\t ]*[\r\n]/g, '');
 myContent.value = myContent.value.replace(/[\t ]*\|[\t ]*translit_lang1_type([1-9]?)[\t ]*=[\t ]*[\r\n][\t ]*\|[\t ]*translit_lang1_info\1[\t ]*=[\t ]*[\r\n]/g, '');
 myContent.value = myContent.value.replace(/[\t ]*\|[\t ]*area_blank1_title[\t ]*=[\t ]*[\r\n][\t ]*\|[\t ]*area_blank1_km2[\t ]*=[\t ]*[\r\n]/g, '');
 myContent.value = myContent.value.replace(/[\t ]*\|[\t ]*(?:length_km|width_km)[\t ]*=[\t ]*[\r\n]/g, '');
 myContent.value = myContent.value.replace(/[\t ]*\|[\t ]*area_(?:total|land|water|urban|rural|metro|blank1|blank2)_ha[\t ]*=[\t ]*[\r\n]/g, '');
 myContent.value = myContent.value.replace(/[\t ]*\|[\t ]*area_(?:blank1|blank2)_title[\t ]*=[\t ]*[\r\n]/g, '');
 myContent.value = myContent.value.replace(/[\t ]*\|[\t ]*area_(?:urban|rural|metro|blank1|blank2)_km2[\t ]*=[\t ]*[\r\n]/g, '');
 myContent.value = myContent.value.replace(/[\t ]*\|[\t ]*area_(?:urban|rural|metro|blank1|blank2)_sq_mi[\t ]*=[\t ]*[\r\n]/g, '');
 myContent.value = myContent.value.replace(/[\t ]*\|[\t ]*area_(?:urban|rural|metro)_footnotes[\t ]*=(?:<(?:)!--(?:<\/ref>|<[\t ]*ref>|[^<>])*-->|[\t ])*[\r\n]/g, '');
 myContent.value = myContent.value.replace(/[\t ]*\|[\t ]*area_magnitude[\t ]*=(?:<(?:)!--(?:<\/ref>|<[\t ]*ref>|[^<>])*-->|[\t ])*[\r\n]/g, '');
 myContent.value = myContent.value.replace(/[\t ]*\|[\t ]*dimensions_footnotes[\t ]*=(?:<(?:)!--(?:<\/ref>|<[\t ]*ref>|[^<>])*-->|[\t ])*[\r\n]/g, '');
 myContent.value = myContent.value.replace(/[\t ]*\|[\t ]*pushpin_label_position[\t ]*=(?:<(?:)!--(?:<\/ref>|<[\t ]*ref>|[^<>])*-->|[\t ])*[\r\n]/g, '');
 myContent.value = myContent.value.replace(/[\t ]*\|[\t ]*population_urban[\t ]*=[\t ]*[\r\n][\t ]*\|[\t ]*population_density_urban_km2[\t ]*=[\t ]*[\r\n][\t ]*\|[\t ]*population_density_urban_sq_mi[\t ]*=[\t ]*[\r\n]/g, '');
 myContent.value = myContent.value.replace(/[\t ]*\|[\t ]*population_rural[\t ]*=[\t ]*[\r\n][\t ]*\|[\t ]*population_density_rural_km2[\t ]*=[\t ]*[\r\n][\t ]*\|[\t ]*population_density_rural_sq_mi[\t ]*=[\t ]*[\r\n]/g, '');
 myContent.value = myContent.value.replace(/[\t ]*\|[\t ]*population_metro[\t ]*=[\t ]*[\r\n][\t ]*\|[\t ]*population_density_metro_km2[\t ]*=[\t ]*[\r\n][\t ]*\|[\t ]*population_density_metro_sq_mi[\t ]*=[\t ]*[\r\n]/g, '');
 myContent.value = myContent.value.replace(/[\t ]*\|[\t ]*population_urban[\t ]*=[\t ]*[\r\n][\t ]*\|[\t ]*population_density_urban_km2[\t ]*=[\t ]*[\r\n]/g, '');
 myContent.value = myContent.value.replace(/[\t ]*\|[\t ]*population_rural[\t ]*=[\t ]*[\r\n][\t ]*\|[\t ]*population_density_rural_km2[\t ]*=[\t ]*[\r\n]/g, '');
 myContent.value = myContent.value.replace(/[\t ]*\|[\t ]*population_metro[\t ]*=[\t ]*[\r\n][\t ]*\|[\t ]*population_density_metro_km2[\t ]*=[\t ]*[\r\n]/g, '');
 myContent.value = myContent.value.replace(/([\r\n][\t ]*\|[\t ]*website[\t ]*=)[\t ]*(http[^ =\r\n]*)[\t ]*([\r\n])/g, '$1\{\{URL|$2\}\}\n');
 myContent.value = myContent.value.replace(/([\r\n][\t ]*\|[\t ]*website[\t ]*=)[\t ]*(http[^ \r\n]*)[\t ]*([\r\n])/g, '$1\{\{URL|1=$2\}\}\n');
 }
 while(myContent.value.search(/[\t\r\n ]*(\{\{[^{}]*\-stub[\t ]*\}\})[\t \r\n]*(\[\[Category:[^\[\]]*\]\]|\{\{DEFAULTSORT:[^{}]*\}\})/gi) >= 0) {
 myContent.value = myContent.value.replace(/[\t\r\n ]*(\{\{[^{}]*\-stub[\t ]*\}\})[\t \r\n]*(\[\[Category:[^\[\]]*\]\]|\{\{DEFAULTSORT:[^{}]*\}\})/gi, '\n$2\n\n$1');
 }
 if(myContent.value.search(/[Gg]eobox/gi) >= 0) {
 if (myContent.value.search(/map[1-2]?_locator/g) >= 0) {
 myContent.value = myContent.value.replace(/[\t ]+=/g, ' =');
 }
 while (myContent.value.search(/[\t ]*\|[\t ]*whs_[a-z]+[\t ]*=[\t ]*([\r\n]|\|)/g)>=0){
 myContent.value = myContent.value.replace(/[\t ]*\|[\t ]*whs_[a-z]+[\t ]*=[\t ]*([\r\n]|\|)/g, '$1');
 }
 myContent.value = myContent.value.replace(/([^\r\n\t ])[\t ]*(<(?:)!-- \*\*)/g, '$1\n$2');
 myContent.value = myContent.value.replace(/(\|[ ]*)(free[0-9]*_)(type[ ]*=[ ]*)([A-Za-z0-9][A-Za-z0-9\t ]*[A-Za-z0-9])[\t ]*([\r\n])[\t ]*\|[\t ]*\2label[\t ]*=[\t ]*\4[\t ]*[\r\n]/g, '$1$2$3$4$5');
 myContent.value = myContent.value.replace(/[\r\n][\t ]*\|[\t ]*capital_coordinates[\t ]*=[\t ]*([\r\n]?[\t ]*\|)/g, '$1');
 for (var i=0; i<5; i++) {
 myContent.value = myContent.value.replace(/([\t ]*\|[\t ]*)(pushpin[^\r\n]*[\r\n])[\t ]*\|[\t ]*map1?_background[ ]*=[ ]*Maine - background map\.png*[\r\n]/g, '$1$2$1pushpin_map_relief = 1\n');
 myContent.value = myContent.value.replace(/([\t ]*\|[\t ]*pushpin[^\r\n]*[\r\n][\t ]*\|[\t ]*)map1?(_size[ ]*=[ ]*[0-9]*)/g, '$1pushpin_map$2');
 myContent.value = myContent.value.replace(/([\t ]*\|[\t ]*pushpin[^\r\n]*[\r\n][\t ]*\|[\t ]*)map1?(_caption[ ]*=)/g, '$1pushpin_map$2');
 myContent.value = myContent.value.replace(/([\t ]*\|[\t ]*pushpin[^\r\n]*[\r\n])[\t ]*\|[\t ]*map1?_(?:first|locator)[ ]*=[ ]*[A-Za-z ]*[\r\n]/g, '$1');
 myContent.value = myContent.value.replace(/([\t ]*\|[\t ]*pushpin[^\r\n]*[\r\n][\t ]*\|[\t ]*)map1?(_alt[ ]*=)/g, '$1pushpin_map$2');
 }
 while( myContent.value.search(/[\r\n]*[\t ]*\|[\t ]*(free[0-9]?)(?:_type|_name|_label|_value|)[\t ]*=[\t ]*[\r\n]*[\t ]*\|[\t ]*\1(?:_type|_name|_label|_value|)[\t ]*=[\t ]*([\r\n]|\||<(?:)!--)/g) >= 0) {
 myContent.value = myContent.value.replace(/[\r\n]*([\t ]*\|[\t ]*)(free[0-9]?)(?:_type|_name|_label|_value|)[\t ]*=[\t ]*[\r\n]*[\t ]*\|[\t ]*\2(?:_type|_name|_label|_value|)[\t ]*=[\t ]*([\r\n]|\||<(?:)!--)/g, '\n$1$2=$3');
 }
 myContent.value = myContent.value.replace(/<(?:)!--[^<>]*Free[^<>]*-->[\t ]*[\r\n][\t ]*(?:\|[\t ]*free[0-9]*[\t ]*=[\t ]*[\r\n]|[\t ]*[\r\n])*(<(?:)!--)/gi, '$1');
 myContent.value = myContent.value.replace(/<(?:)!--[^<>]*Free[^<>]*-->[\t ]*[\r\n](<(?:)!--)/gi, '$1');
 myContent.value = myContent.value.replace(/[\t ]*[\r\n][\t ]*\|[\t ]*free[0-9]*[\t ]*=[\t ]*([\r\n][\t ]*\||[\r\n]<(?:)!--)/gi, '$1');
 }
 if (config.wgNamespaceNumber === 0 && myContent.value.search(/\{subst:/g) >= 0) {
 myContent.value = myContent.value.replace(/(\{)(subst:)/g, '$1¶¶¶$2');
 myContent.value = myContent.value.replace(/(<)(ref|poem|!--|nowiki|gallery)/gi, '$1{'+'{subst:void}'+'}$2');
 myContent.value = myContent.value.replace(/(<)\{\{[ ]*subst[ ]*:[ ]*void[ ]*\}\}(!--[^<>¶]*-->)/g, '$1$2');
 myContent.value = myContent.value.replace(/(<)\{\{[ ]*subst[ ]*:[ ]*void[ ]*\}\}(ref[^<>\/]*\/>)/gi, '$1$2');
 myContent.value = myContent.value.replace(/(<)\{\{[ ]*subst[ ]*:[ ]*void[ ]*\}\}(nowiki[^<>\/]*\/>)/gi, '$1$2');
 myContent.value = myContent.value.replace(/(<)\{\{[ ]*subst[ ]*:[ ]*void[ ]*\}\}(ref[^<>\/]*>[^<>¶]*<\/ref>)/gi, '$1$2');
 myContent.value = myContent.value.replace(/(<)\{\{[ ]*subst[ ]*:[ ]*void[ ]*\}\}(nowiki[^<>\/]*>[^<>¶]*<\/nowiki>)/gi, '$1$2');
 myContent.value = myContent.value.replace(/(<)\{\{[ ]*subst[ ]*:[ ]*void[ ]*\}\}(poem[^<>\/]*>[^<>¶]*<\/poem>)/gi, '$1$2');
 myContent.value = myContent.value.replace(/(\{)¶¶¶(subst:)/g, '$1$2');
 }
 if(myContent.value != oldtext) {
 var editsummary = document.getElementsByName('wpSummary')[0];
 if(myContent.value.search(/[Gg]eobox/gi) >= 0) {
 editsummary.value = 'replace deprecated "geobox2 map" with [[template:location map|location map]]-based map';
 } else if(myContent.value.search(/[Ff]b[_ ]+match/gi) >= 0) {
 editsummary.value = 'replace fb match per TfD outcome';
 } else {
 editsummary.value = 'update template syntax';
 }
 document.forms.editform.wpDiff.click();
 oldtext = myContent.value;
 }
 myContent.value = myContent.value.replace(/(The points system worked as follows:)[\s]*\*[\t ]*([^\r\n]*)[\r\n]\*[\t ]*/g, '$1 $2 and ');
 myContent.value = myContent.value.replace(/(\}\}(?:<\/onlyinclude>|))[\t ]*[\r\n]*[\t ]*[\r\n]*(The points system worked[^\r\n\.]*)[\. ]*[\r\n]/g, '|class_rules = 1) points. $2.\n$1\n');
 myContent.value = myContent.value.replace(/(\{\{)[\s_ ]*[Ii]nfobox[_\s]*(GAA)[_\s]*(match)/g, '$1$2 $3');
 myContent.value = myContent.value.replace(/(\{\{)[\s_ ]*([Ff]ootball)[_\s]*(box)[_\s]*(collapsible)/g, '$1$2 $3 $4');
 myContent.value = myContent.value.replace(/<(?:div|span) id[ ]*=[ ]*"([^"<>]*)"[ ]*>(?:[\t ]|<\/span>|[\r\n])*(\{\{(?:[Bb]asketball|[Ff]ootball)[ ]*box[^\r\n]*)((?:[^{}]|\{\{[^{}]*\}\})*\}\})[\t\r\n ]*<\/(?:div|span)>/gi, '$2|id=$1$3');
 myContent.value = myContent.value.replace(/<(?:div|span) id[ ]*=[ ]*"([^"<>]*)"[ ]*>(?:[\t ]|<\/span>|[\r\n])*(\{\{(?:[Bb]asketball|[Ff]ootball)[ ]*box[^\r\n]*)/gi, '$2|id=$1');
 myContent.value = myContent.value.replace(/(\|[ ]*class[ ]*=[ ]*collapsible)[ ]*v?event/g, '$1');
 myContent.value = myContent.value.replace(/\|[ ]*stack[ ]*=[A-Za-z ]*(\}\}|\|)/g, '$1');
 myContent.value = myContent.value.replace(/\|[ ]*stack[ ]*=[A-Za-z ]*[\r\n]/g, '');
 myContent.value = myContent.value.replace(/\|[ ]*size[ ]*=[ ]*100%[ ]*[\r\n]/g, '');
 myContent.value = myContent.value.replace(/(\{\{)[\s_]*([Ff]ootball)[\s_]*(box[^\r\n\|]*)\|[\t ]*[\r\n]([\t ]*\|)/g, '$1$2 $3\n$4');
 myContent.value = myContent.value.replace(/(\{\{)[\s_]*([Ff]ootball)[\s_]*(box[^\r\n\|]*)(\|[^\r\n]*[\r\n]\|)/g, '$1$2 $3\n$4');
 myContent.value = myContent.value.replace(/([^\{])\{\{[Ss]mall[\t ]*\|[\t ]*\}\}/g, '$1');
 myContent.value = myContent.value.replace(/(\{\{)[_\t ]*NCAATeamFootballSeason[_\t ]*[\r\n]*([\t ]*\|[\t ]*)([A-Za-z]*)([\t ]*=[\t ]*)/gi, '$1Infobox NCAA team season\n$2sport$4football\n$2$3$4');
 myContent.value = myContent.value.replace(/<[ ]*div[ ]*style[ ]*=["' ]*margin\-top[ ]*:[ ]*15px[;'"] *>[\t ]*[\r\n]*[\t ]*[\r\n]*/gi, '');
 myContent.value = myContent.value.replace(/<[\/ ]*br[^<>]*>[\t ]*([\r\n]\*)/gi, '$1');
 myContent.value = myContent.value.replace(/(average attend)(?:https:[^=]*|)(ance[ ]*=[ ]*)(?:5,157|)/g, '$1$2');
 myContent.value = myContent.value.replace(/==[ ]*Squad information[ ]*==[ ]*[\r\n]*[\t ]*[\r\n]*\{\{[Ee]mpty section[^{}]*\}\}[ ]*[\r\n]*/g, '');
 myContent.value = myContent.value.replace(/(==[ ]*(?:Representative|Other)[ ]+)M(atch(?:es|)[ ]*==)/gi, '$1m$2');
 myContent.value = myContent.value.replace(/(==[ ]*Reserve[ ]+)T(eam[ ]*==)/gi, '$1t$2');
 myContent.value = myContent.value.replace(/(==[ ]*Match[ ]+)R(esults[ ]*==)/gi, '$1r$2');
 myContent.value = myContent.value.replace(/(==[ ]*International[ ]+)C(aps[ ]*==)/gi, '$1c$2');
 myContent.value = myContent.value.replace(/(==[ ]*Story of the[ ]+)S(eason[ ]*==)/gi, '$1s$2');
 myContent.value = myContent.value.replace(/(==[ ]*Season[ ]+)S(ummary[ ]*==)/gi, '$1s$2');
 myContent.value = myContent.value.replace(/(==[ ]*Top[ ]+)S(corers[ ]*==)/gi, '$1s$2');
 myContent.value = myContent.value.replace(/(==[ ]*Top[ ]+)G(oalscorers[ ]*==)/gi, '$1g$2');
 myContent.value = myContent.value.replace(/(==[ ]*[^= \r\n]+[^=\r\n]*[ ]+)T(able[ ]*==)/gi, '$1t$2');
 myContent.value = myContent.value.replace(/(==[ ]*Results)[ ]+(?:and|And|\&)[ ]+[Ff](ixtures[ ]*==)/gi, '$1 and f$2');
 if (myContent.value.search(/<[\t ]*center/gi) < 0) {
 myContent.value = myContent.value.replace(/<\/center>/gi, '');
 }
 if (myContent.value.search(/<[\t ]*span/gi) < 0) {
 myContent.value = myContent.value.replace(/<\/span>/gi, '');
 }
 if (myContent.value.search(/<[\t ]*div/gi) < 0) {
 myContent.value = myContent.value.replace(/<\/div>/gi, '');
 }
 // End of line pipes
 myContent.value = myContent.value.replace(/[\t ]*\|[\t ]*[\r\n][\t ]*([^!<>\*#\|\[\]\{\} \r\n\t=][^!<>\*#\|\[\]\{\}\r\n=]*=)/g, '\n|$1');
 myContent.value = myContent.value.replace(/[\t ]*\|[\t ]*[\r\n][\t ]*[\r\n][\t ]*([^!<>\*#\|\[\]\{\} \r\n\t=][^!<>\*#\|\[\]\{\}\r\n=]*=)/g, '\n\n|$1');
 // myContent.value = myContent.value.replace(/\{\{subst:lc:([^\{\}]*)\}\}/g, function(match) {return match.toLowerCase();});
 // myContent.value = myContent.value.replace(/\{\{subst:lc:([^\{\}]*)\}\}/g, '$1');
 myContent.value = myContent.value.replace(/(map_caption[ ]*=[ ]*)\{\{sp\}\}[\t ]*<(?:)!--[\t ]*none[\t ]*-->/gi, '$1none');
 // myContent.value = myContent.value.replace(/<center>[\t ]*[\r\n]\{\|(?:[^{}]|[\r\n])*\{\|(?:[^'{}]|[\r\n])*'''([^'\r\n]*)'''(?:[^{}]|[\r\n])*\}(?:[^{}!]|[\r\n])*![\t ]*!![\t ]*TEAM[^\r\n]*/gi, '{'+'{AFLLadderHeader||name=$1}}');
 if(myContent.value.search(/\{\{[_\t ]*[Cc]olend/g) >= 0 ) {
 myContent.value = myContent.value.replace(/(\{\{)[\t _]*[Dd]iv[\t _]*col[\t _]*(\||\}\})/g, '$1colbegin$2');
 myContent.value = myContent.value.replace(/(\{\{)[\t _]*[Dd]iv[\t _]*col[\t _]*end(\||\}\})/g, '$1colend$2');
 }
 myContent.value = myContent.value.replace(/\{\{e\}\}/gi, '<sup>e</sup>');
 myContent.value = myContent.value.replace(/([\r\n][\*: ]*|=[ ]*)((?:\[\[[^\[\]]*\]\]|[^\r\n\{\}=\[\]\|])*?\{\{[^e!'0=YyNn₱\-]\}\}(?:\[\[[^\[\]]*\]\]|[^\r\n\{\}=\[\]\|])*\{\{[^!'0=YyNn\-]\}\}(?:\[\[[^\[\]]*\]\]|[^\r\n\{\}=\[\]\|])*)/g, '$1{'+'{hlist|$2}'+'}');
 lt = ''
 while(myContent.value != lt) {
 lt = myContent.value;
 myContent.value = myContent.value.replace(/(\{\{hlist\|[^\{\}]*)\{\{[^!'0=YyNn\-]\}\}/g, '$1|');
 myContent.value = myContent.value.replace(/(\{\{UAAPteam standings[^{}]*\}\})[\t ]*[\r\n]*((?:Event|Season) host[^\r\n]*?|\{\{legend2[^{}]*\}\})(?:<br[^<>]*>|[\t ])*([\r\n])/g, '$1{'+'{ubl\n|$2\n}'+'}\n');
 myContent.value = myContent.value.replace(/(\{\{UAAPteam standings[^{}]*\}\}\{\{ubl(?:[^{}]|\{\{legend2[^{}]*\}\})*)(\}\})[\t ]*[\r\n]*[\t ]*(\{\{legend2[^{}]*\}\})(?:<br[^<>]*>|[\t ])*/g, '$1|$3\n$2');
 }
 // duplicate args
 // myContent.value = myContent.value.replace(/(\{\{[^{}]*)\|[ ]*([A-Za-z_\-0-9]+)[ ]*=[ ]*((?:[^{}\|\[\]]|\[\[[^\[\]]*\]\])*)[\t \r\n]*((?:\|[^{}]*|)\|[ ]*\2[ ]*=[ ]*\3)/g, '$1$4');
 // myContent.value = myContent.value.replace(/(\{\{[^{}]*\|[ ]*)([A-Za-z_\-0-9]+)([ ]*=[^{}]*\|[ ]*\2[ ]*=)/g, '$1DUPLICATE-$2$3');
 
 if(myContent.value != oldtext) {
 alert('Check changes!');
 oldtext = myContent.value;
 }
 if ( myContent.value.search(/<(?:)!--[ ]*SORT[ ]*-->/g) >= 0 ) {
 myContent.value = myContent.value.replace(/(\|[ ]*[a-z_]*years[ ]*1[ ]*=)/g, '| FBARRIER =\n$1');
 for(var i=1; i<=20; i++) {
 var j = '(?:' + (i+1);
 for(var i2=(i+2); i2<=21; i2++) {
 j = j + '|' + i2;
 }
 j = j + ')';
 var k=0;
 var r = new RegExp('(\\|[\\t \\r\\n]*[A-Za-z_]+' 
 + j + '[\\t \\r\\n]*=(?:[^\\[\\]\\|\\{\\}]|\\[\\[[^\\[\\]]*\\]\\]|\\{\\{[^\\{\\}]*\\}\\}|\\[[^\\[\\]]*\]|[\\r\\n])*)(\\|[\\t \\r\\n]*[A-Za-z_]+' 
 + i + '[\\t \\r\\n]*=(?:[^\\[\\]\\|\\{\\}]|\\[\\[[^\\[\\]]*\\]\\]|\\{\\{[^\\{\\}]*\\}\\}|\\[[^\\[\\]]*\]|[\\r\\n])*)', 'gi');
 while( myContent.value.search(r) >= 0 && k < 100) {
 myContent.value = myContent.value.replace(r, '$2$1');
 k = k + 1;
 }
 }
 myContent.value = myContent.value.replace(/[\t ]*\|[\t ]*FBARRIER[ ]*=[\t \r\n]*/g, '');
 myContent.value = myContent.value.replace(/<(?:)!--[ ]*SORT[ ]*-->[\t ]*/g, '');
 }
 if(myContent.value != oldtext) {
 alert('Check changes!');
 oldtext = myContent.value;
 }
 myContent.value = myContent.value.replace(/([\r\n][:\*;\t ]*)<span style="font-family[ ]*:[ ]*Courier New;?["”][ ]*>([^<>]*)<\/span>/g, '$1{'+'{player|$2}}');
 myContent.value = myContent.value.replace(/([\r\n][:\*;\t ]*)(\'\')[\t ]*<span style="font-family[ ]*:[ ]*Courier New;?["”][ ]*>([^<>]*)<\/span>[\t ]*/g, '$1{'+'{player|$3}} $2');
 
 myContent.value = myContent.value.replace(/\{\{(?:[Bb]reak|[Bb]rk|[Nn]ewline|[Cc]rlf|[Nn]extline|[Ll]ine[_ ]+break)[1\| ]*([\r\n]?)\}\}/g, '<br $1/>');
 if(0) {
 myContent.value = myContent.value.replace(/(style[ ]*=[ ]*")([^"\|]*"[ ]*\|[ ]*)\{\{[Tt]?[Nn]avbar\-header\|[']*([^'\|\{\}]*)[' ]*\|[^{}]*fontcolor[ ]*=[ ]*([^{}\|]*)\}\}/g, '$1text-align:center; color:$4; $2$3');
 myContent.value = myContent.value.replace(/([\r\n])<span(?: class="plainlinks"|)>([^<>]*)<\/span>/g, '$1* $2');
 myContent.value = myContent.value.replace(/([\r\n])<small>/g, '$1* ');
 myContent.value = myContent.value.replace(/<br[^<>]*>[\t ]*([\r\n]\*)/gi, '$1');
 myContent.value = myContent.value.replace(/([\r\n][\t ]*)([\r\n]\*[\t ]*\'(?:[^<>]|[\r\n])*)<\/small>/g, '$1{'+'{plainlist|1=$2\n}}');
 }
 myContent.value = myContent.value.replace(/(title[ ]*=)[\t ]*(ACTUAL ARTICLE TITLE BELONGS HERE!?)[\t ]*/g, '$1<'+'!--$2-->');
 myContent.value = myContent.value.replace(/(\|[ ]*)([a-z][a-z0-9_]+)([ ]*=[ ]*\-?[0-9][0-9,\.]*)[ ]*(\{\{[Gg]eo)/g, '$1$2$3 | $2_note = $4');
 if (config.wgNamespaceNumber === 0 && myContent.value.search(/\{subst:/g) >= 0) {
 myContent.value = myContent.value.replace(/(\{)(subst:)/g, '$1¶¶¶$2');
 myContent.value = myContent.value.replace(/(<)(ref|poem|!--|nowiki|gallery)/gi, '$1{'+'{subst:void}'+'}$2');
 myContent.value = myContent.value.replace(/(<)\{\{[ ]*subst[ ]*:[ ]*void[ ]*\}\}(!--[^<>¶]*-->)/g, '$1$2');
 myContent.value = myContent.value.replace(/(<)\{\{[ ]*subst[ ]*:[ ]*void[ ]*\}\}(ref[^<>\/]*\/>)/gi, '$1$2');
 myContent.value = myContent.value.replace(/(<)\{\{[ ]*subst[ ]*:[ ]*void[ ]*\}\}(nowiki[^<>\/]*\/>)/gi, '$1$2');
 myContent.value = myContent.value.replace(/(<)\{\{[ ]*subst[ ]*:[ ]*void[ ]*\}\}(ref[^<>\/]*>[^<>¶]*<\/ref>)/gi, '$1$2');
 myContent.value = myContent.value.replace(/(<)\{\{[ ]*subst[ ]*:[ ]*void[ ]*\}\}(nowiki[^<>\/]*>[^<>¶]*<\/nowiki>)/gi, '$1$2');
 myContent.value = myContent.value.replace(/(<)\{\{[ ]*subst[ ]*:[ ]*void[ ]*\}\}(poem[^<>\/]*>[^<>¶]*<\/poem>)/gi, '$1$2');
 myContent.value = myContent.value.replace(/(\{)¶¶¶(subst:)/g, '$1$2');
 }
 if(myContent.value != oldtext) {
 alert('Check changes!');
 oldtext = myContent.value;
 }
 if( myContent.value.search(/\{\{[_\t ]*Baseball[_ ]+[Nn]avbox/g) >= 0 ) {
 myContent.value = myContent.value.replace(/<span[^<>]*>/gi, '');
 myContent.value = myContent.value.replace(/<\/span>/gi, '');
 }
 if( myContent.value.search(/\{\{[_\t ]*(?:Baseball[_ ]+|)[Nn]avbox/g) >= 0 ) {
 myContent.value = myContent.value.replace(/(\[\[)[\t ]*([^\[\]\|]+)[\t ]*(\|)[\t ]*([^\[\]\|]+)[\t ]*(\]\])/g, '$1$2$3$4$5');
 myContent.value = myContent.value.replace(/<\/noinclude>[\t ]*<noinclude>/g, '');
 myContent.value = myContent.value.replace(/(\}\})([\t ]*[\r\n]*[\t ]*)(<noinclude>)/gi, '$1$3$2');
 if (mw.config.get('wgNamespaceNumber') == 10) {
 myContent.value = myContent.value.replace(/(title[ ]*=[ ]*)([^\r\n]*)(\{\{flagicon[^{}]*\}\})/gi, '$1$3 $2');
 myContent.value = myContent.value.replace(/(\*[\t ]*\[\[):Category:([0-9]+ in)/gi, '$1$2');
 myContent.value = myContent.value.replace(/(\*[\t ]*\[\[)(20(?:19|2[0-9]) in)/gi, '$1:Category:$2');
 // myContent.value = myContent.value.replace(/(\|[ ]*state[ ]*=[ ]*)(collapsed)/g, '$1<includeonly>$2</includeonly>');
 myContent.value = myContent.value.replace(/(\|[ ]*state[ ]*=[ ]*\{\{\{state\|)(collapsed)(\}\}\})/g, '$1<includeonly>$2</includeonly>$3');
 myContent.value = myContent.value.replace(/[\r\n]*[\t ]*\|[ ]*evenodd[ ]*=[ ]*swap[; ]*([\r\n]*[\t ]*\|)/g, '$1');
 }
 myContent.value = myContent.value.replace(/groupstyle[ ]*=[ ]*width[ ]*:[ ]*([^;\r\n ]*)[\t ]*[;\t ]*([\r\n]|\|)/g, 'groupwidth = $1$2');
 myContent.value = myContent.value.replace(/groupstyle[ ]*=[ ]*width[ ]*:[ ]*([^;\r\n ]*)[\t ]*;/g, 'groupwidth = $1| groupstyle = ');
 myContent.value = myContent.value.replace(/[\r\n]*[\t ]*\|[ ]*liststyle[ ]*=[ ]*width[ ]*:[ ]*auto[; ]*([\r\n]*[\t ]*\|)/g, '\n$1');
 myContent.value = myContent.value.replace(/[\r\n]*[\t ]*\|[ ]*liststyle[ ]*=[; ]*([\r\n]*[\t ]*\|)/g, '$1');
 myContent.value = myContent.value.replace(/[\r\n]*[\t ]*\|[ ]*groupstyle[ ]*=[; ]*([\r\n]*[\t ]*\|)/g, '$1');
 myContent.value = myContent.value.replace(/[\r\n]*[\t ]*\|[ ]*evenstyle[ ]*=[; ]*([\r\n]*[\t ]*\|)/g, '$1');
 myContent.value = myContent.value.replace(/[\r\n]*[\t ]*\|[ ]*oddstyle[ ]*=[; ]*([\r\n]*[\t ]*\|)/g, '$1');
 myContent.value = myContent.value.replace(/[\r\n]*[\t ]*\|[ ]*liststyle[ ]*=[ ]*background:(?:#ffffff|#f7f7f7|transparent)[; ]*([\r\n]*[\t ]*\|)/g, '$1');
 myContent.value = myContent.value.replace(/[\r\n]*[\t ]*\|[ ]*evenstyle[ ]*=[ ]*background:(?:#ffffff|#f7f7f7|transparent)[; ]*([\r\n]*[\t ]*\|)/g, '$1');
 myContent.value = myContent.value.replace(/[\r\n]*[\t ]*\|[ ]*oddstyle[ ]*=[ ]*background:(?:#ffffff|#f7f7f7|transparent)[; ]*([\r\n]*[\t ]*\|)/g, '$1');
 myContent.value = myContent.value.replace(/(belowstyle[ ]*=[ ]*)(background:transparent;|)[ ]*border-top:[ ]*1px [ ]*solid [ ]*([#A-Fa-f0-9]+)[ ]*;/g, '$1$2{'+'{box-shadow border|t|$3}}');
 myContent.value = myContent.value.replace(/(belowstyle[ ]*=[ ]*)(background:transparent;|)[ ]*border-top:[ ]*([#A-Fa-f0-9]+)[ ]*1px [ ]*solid;/g, '$1$2{'+'{box-shadow border|t|$3}}');
 myContent.value = myContent.value.replace(/(\{\{)Infobox basketball biography\/style/g, '$1basketball color cell');
 myContent.value = myContent.value.replace(/((?:abovestyle|basestyle|group[0-9]*style|belowstyle)[ ]*=[^\r\n\|]*)border[ ]*:[ ]*([#A-Za-z0-9][A-Za-z0-9]*) ([1-5]px) solid[; ]*/g, '$1{'+'{box-shadow border|a|$2|$3}}');
 myContent.value = myContent.value.replace(/((?:abovestyle|basestyle|group[0-9]*style|belowstyle)[ ]*=[^\r\n\|]*)border[ ]*:[ ]*([#A-Za-z0-9][A-Za-z0-9]*) solid ([1-5]px)[; ]*/g, '$1{'+'{box-shadow border|a|$2|$3}}');
 myContent.value = myContent.value.replace(/((?:abovestyle|basestyle|group[0-9]*style|belowstyle)[ ]*=[^\r\n\|]*)border[ ]*:[ ]*solid ([#A-Za-z0-9][A-Za-z0-9]*) ([1-5]px)[; ]*/g, '$1{'+'{box-shadow border|a|$2|$3}}');
 myContent.value = myContent.value.replace(/((?:abovestyle|basestyle|group[0-9]*style|belowstyle)[ ]*=[^\r\n\|]*)border[ ]*:[ ]*([1-5]px) ([#A-Za-z0-9][A-Za-z0-9]*) solid[; ]*/g, '$1{'+'{box-shadow border|a|$2|$3}}'); 
 myContent.value = myContent.value.replace(/((?:abovestyle|basestyle|group[0-9]*style|belowstyle)[ ]*=[^\r\n\|]*)border[ ]*:[ ]*([1-5]px) solid ([#A-Za-z0-9][A-Za-z0-9]*)[; ]*/g, '$1{'+'{box-shadow border|a|$3|$2}}');
 myContent.value = myContent.value.replace(/((?:abovestyle|basestyle|group[0-9]*style|belowstyle)[ ]*=[^\r\n\|]*)border[ ]*:[ ]*solid ([1-5]px) ([#A-Za-z0-9][A-Za-z0-9]*)[; ]*/g, '$1{'+'{box-shadow border|a|$3|$2}}');
 if(myContent.value.match(/box-shadow border/g).length > 1) {
 myContent.value = myContent.value.replace(/((?:titlestyle|abovestyle|basestyle|group[0-9]*style|belowstyle)[ ]*=[^\r\n\|]*)border[ ]*:[ ]*([#A-Za-z0-9][A-Za-z0-9]*) ([1-5]px) solid[; ]*/g, '$1{'+'{box-shadow border|a|$2|$3}}');
 myContent.value = myContent.value.replace(/((?:titlestyle|abovestyle|basestyle|group[0-9]*style|belowstyle)[ ]*=[^\r\n\|]*)border[ ]*:[ ]*([#A-Za-z0-9][A-Za-z0-9]*) solid ([1-5]px)[; ]*/g, '$1{'+'{box-shadow border|a|$2|$3}}');
 myContent.value = myContent.value.replace(/((?:titlestyle|abovestyle|basestyle|group[0-9]*style|belowstyle)[ ]*=[^\r\n\|]*)border[ ]*:[ ]*solid ([#A-Za-z0-9][A-Za-z0-9]*) ([1-5]px)[; ]*/g, '$1{'+'{box-shadow border|a|$2|$3}}');
 myContent.value = myContent.value.replace(/((?:titlestyle|abovestyle|basestyle|group[0-9]*style|belowstyle)[ ]*=[^\r\n\|]*)border[ ]*:[ ]*([1-5]px) ([#A-Za-z0-9][A-Za-z0-9]*) solid[; ]*/g, '$1{'+'{box-shadow border|a|$2|$3}}'); 
 myContent.value = myContent.value.replace(/((?:titlestyle|abovestyle|basestyle|group[0-9]*style|belowstyle)[ ]*=[^\r\n\|]*)border[ ]*:[ ]*([1-5]px) solid ([#A-Za-z0-9][A-Za-z0-9]*)[; ]*/g, '$1{'+'{box-shadow border|a|$3|$2}}');
 myContent.value = myContent.value.replace(/((?:titlestyle|abovestyle|basestyle|group[0-9]*style|belowstyle)[ ]*=[^\r\n\|]*)border[ ]*:[ ]*solid ([1-5]px) ([#A-Za-z0-9][A-Za-z0-9]*)[; ]*/g, '$1{'+'{box-shadow border|a|$3|$2}}');
 }
 myContent.value = myContent.value.replace(/(group[0-9][0-9]*[ ]*=[ ]*)<span[^<>]*>([^<>]*)<\/span>/gi, '$1$2');
 myContent.value = myContent.value.replace(/[ ]*\|[ ]*(list[0-9]+)style[ ]*=[ ]*background-color:#e6e6ff;[ ]*font-weight:bold;[ ]*[\r\n]*(\|[ ]*)\1([ ]*=[ ]*)([^\r\n]*)/g, '$2$1$3{'+'{navbox|subgroup|above=\'\'\'$4\'\'\'}}');
 }
 if (myContent.value.match(/class[ ]*=[ ]*hlist/g).length > 1) {
 alert('Check multiple hlist classes');
 }
 if (myContent.value.search(/(?:evenstyle|oddstyle|evenodd|list[0-9]*style)[ ]*=/g) >= 0) {
 alert('Check evenodd / liststyle');
 }
 if (myContent.value.search(/width[ ]*:[ ]*/g) >= 0) {
 alert('Check width');
 }
 if (myContent.value.search(/\[\[Category:/g) < 0 && mw.config.get('wgNamespaceNumber') == 10) {
 if (myContent.value.search(/[Dd]ocumentation\|Wikipedia:WikiProject Mammals\/Article templates\/doc/g) < 0) {
 alert('Add categories?');
 }
 }
 if(myContent.value != oldtext) {
 alert('Check changes!');
 oldtext = myContent.value;
 }
 if(myContent.value != oldtext ) {
 var editsummary = document.getElementsByName('wpSummary')[0];
 editsummary.value = 'navbox syntax update';
 }

 } 
 if(myContent && mw.config.get('wgUserName') == 'Frietjes') {
 mw.loader.using(['mediawiki.util']).done( function() {
 try { wpCleanNavbox(); } catch (e) {
 mw.log.error(e);
 }
 });
 }
});
// </nowiki>