Jump to content
Wikipedia The Free Encyclopedia

Wikipedia:WikiProject User scripts/Scripts/Replace

From Wikipedia, the free encyclopedia

//

// Adds a "Replace" tab which pops up two prompt boxes; one for a regexp and one for a replacement
functionwpTextboxReplace()
{
vars=prompt("Search regexp:");
vartxt=document.editform.wpTextbox1;
while(true){
if(!s)return;
vars_r=newRegExp(s,"mg");
if(s_r.test(txt.value)){
varr=prompt("Replace /"+s+"/ with:");
r=r.replace(/\\n/g,"\n");// unescape newlines
if(!r&&r!=='')return;
txt.value=txt.value.replace(s_r,r);
return;
}
else{
vars_0=s;
s=prompt("/"+s_0+"/ did not match anything. You may enter a new regexp:");
}
}
}
addOnloadHook(function(){
if(document.forms.editform){
mw.util.addPortletLink('p-cactions','javascript:wpTextboxReplace()','Replace','ca-replace',
'Regexp replace for the edit window','R',document.getElementById('ca-history'));
}
});

//

//

AltStyle によって変換されたページ (->オリジナル) /