Wikipedia:WikiProject User scripts/Scripts/Replace

This is an old revision of this page, as edited by ABCD (talk | contribs) at 05:01, 18 October 2007 (might as well do syntax highlighting...). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

//

function wpTextboxReplace()
{
    var s = prompt("Search regexp:");
    if(s){
        var r = prompt("Replace /"+s+"/ with:");
        if(!r && r != '') return;
        var txt = document.editform.wpTextbox1;
        txt.value = txt.value.replace(new RegExp(s, "mg"), r);
    }
}
addOnloadHook(function () {
    if (document.forms.editform) {
        addPortletLink('p-cactions', 'javascript:wpTextboxReplace()', 'Replace', 'ca-replace',
                       'Regexp replace for the edit window', 'R', document.getElementById('ca-history'));
    }
});

//

//