---- NOTE: while I haven't looked through quite carefully enough, I think that [[Module:String]]---- can do everything that this can do. I may put it up for deletion soon.---- Sorry, this doesn't work for many applications because all templates are destroyed. It does work on plain text though.---- This module is meant to be processed by putting ---- "{{#invoke:FindAndReplace|main|(string to find)|(string to replace)}}"---- into an existing page. Add "|pattern=yes" to enjoy all the wild and wooly---- features of Lua pattern strings. This should deliver back all the text,---- as modified, in wiki source form, for you to copy and paste back into the---- page while editing. Caveat: I don't presently know if things like comments---- will be lost. This is intended as a handy tool for editors who don't have---- find and replace on their browser and don't want to open another program ----- or to provide better Lua find and replace where their word processors come---- up short. NOTE that text MUST be saved to be processed with this unless---- you use an additional parameter |input=(the text to find and replace from)localp={}functionp.main(frame)localargs=frame.argslocalparent=frame.getParent(frame)localpargs={}ifparentthenpargs=parent.argsendlocalfind=args.findorpargs.findorargs[1]orpargs[1]ifnot(find)thenreturn"error you need to say what to find! (first unnamed parameter ''or'' find=(text)"endlocalreplace=args.replaceorpargs.replaceorargs[2]orpargs[2]or""localpattern=args.patternorpargs.patternor"no"ifpattern=="no"thenpattern=nilendlocalinput=args.inputorpargs.inputorargs[3]orpargs[3]or""ifinput==nilorinput==""thenreturn"failed to get any text"endinput=mw.ustring.gsub(input,"{{#invoke:FindAndReplace.-}}","")orinput--we don't want shrapnel from this usage in the new page.ifnot(pattern)thenfind=string.gsub(find,"[%^%$%(%)%%%.%[%]%*%+%-%?%]]","%%1")end-- exterminate all delimitersinput=mw.ustring.gsub(input,find,replace)---- I have no idea why {{x gets returned as [[:Template:x but I don't like it.--input=mw.ustring.gsub(input,[=[%[%[:Template:]=].."(.-)"..[=[%]%]]=],"{{%1}}")-- no good - it still loses all the parameters out of all the templates!returnframe.preprocess(frame,"<pre><nowiki>"..input..[[</nowiki></pre>]])endreturnp-- I wonder if there's a way to put this directly back into an open edit window...