<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3ASandbox%2FWnt%2FFindAndReplace</id>
	<title>Module:Sandbox/Wnt/FindAndReplace - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3ASandbox%2FWnt%2FFindAndReplace"/>
	<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Sandbox/Wnt/FindAndReplace&amp;action=history"/>
	<updated>2026-04-18T02:13:26Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://stockhub.co/index.php?title=Module:Sandbox/Wnt/FindAndReplace&amp;diff=146406&amp;oldid=prev</id>
		<title>imported&gt;Wnt: Wnt moved page Module:FindAndReplace to Module:Sandbox/Wnt/FindAndReplace without leaving a redirect: No need to keep this in Module space if someone objects</title>
		<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Sandbox/Wnt/FindAndReplace&amp;diff=146406&amp;oldid=prev"/>
		<updated>2018-05-09T00:38:08Z</updated>

		<summary type="html">&lt;p&gt;Wnt moved page &lt;a href=&quot;/index.php?title=Module:FindAndReplace&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Module:FindAndReplace (page does not exist)&quot;&gt;Module:FindAndReplace&lt;/a&gt; to &lt;a href=&quot;/research/Module:Sandbox/Wnt/FindAndReplace&quot; title=&quot;Module:Sandbox/Wnt/FindAndReplace&quot;&gt;Module:Sandbox/Wnt/FindAndReplace&lt;/a&gt; without leaving a redirect: No need to keep this in Module space if someone objects&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt; ---- NOTE: while I haven&amp;#039;t looked through quite carefully enough, I think that [[Module:String]]&lt;br /&gt;
 ---- can do everything that this can do.  I may put it up for deletion soon.&lt;br /&gt;
 ---- Sorry, this doesn&amp;#039;t work for many applications because all templates are destroyed.  It does work on plain text though.&lt;br /&gt;
&lt;br /&gt;
---- This module is meant to be processed by putting &lt;br /&gt;
 ---- &amp;quot;{{#invoke:FindAndReplace|main|(string to find)|(string to replace)}}&amp;quot;&lt;br /&gt;
 ---- into an existing page.  Add &amp;quot;|pattern=yes&amp;quot; to enjoy all the wild and wooly&lt;br /&gt;
 ---- features of Lua pattern strings.  This should deliver back all the text,&lt;br /&gt;
 ---- as modified, in wiki source form, for you to copy and paste back into the&lt;br /&gt;
 ---- page while editing.  Caveat: I don&amp;#039;t presently know if things like comments&lt;br /&gt;
 ---- will be lost.  This is intended as a handy tool for editors who don&amp;#039;t have&lt;br /&gt;
 ---- find and replace on their browser and don&amp;#039;t want to open another program -&lt;br /&gt;
 ---- or to provide better Lua find and replace where their word processors come&lt;br /&gt;
 ---- up short.  NOTE that text MUST be saved to be processed with this unless&lt;br /&gt;
 ---- you use an additional parameter |input=(the text to find and replace from)&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
   local args=frame.args&lt;br /&gt;
   local parent=frame.getParent(frame)&lt;br /&gt;
   local pargs={}&lt;br /&gt;
   if parent then pargs=parent.args end&lt;br /&gt;
   local find=args.find or pargs.find or args[1] or pargs[1]&lt;br /&gt;
   if not(find) then return &amp;quot;error you need to say what to find! (first unnamed parameter &amp;#039;&amp;#039;or&amp;#039;&amp;#039; find=(text)&amp;quot; end&lt;br /&gt;
   local replace=args.replace or pargs.replace or args[2] or pargs[2] or &amp;quot;&amp;quot;&lt;br /&gt;
   local pattern=args.pattern or pargs.pattern or &amp;quot;no&amp;quot;&lt;br /&gt;
   if pattern==&amp;quot;no&amp;quot; then pattern = nil end&lt;br /&gt;
   local input=args.input or pargs.input or args[3] or pargs[3] or &amp;quot;&amp;quot;&lt;br /&gt;
   if input == nil or input == &amp;quot;&amp;quot; then return &amp;quot;failed to get any text&amp;quot; end&lt;br /&gt;
   input=mw.ustring.gsub(input,&amp;quot;{{#invoke:FindAndReplace.-}}&amp;quot;,&amp;quot;&amp;quot;) or input --we don&amp;#039;t want shrapnel from this usage in the new page.&lt;br /&gt;
   if not(pattern) then find=string.gsub(find,&amp;quot;[%^%$%(%)%%%.%[%]%*%+%-%?%]]&amp;quot;,&amp;quot;%%1&amp;quot;) end -- exterminate all delimiters&lt;br /&gt;
   input=mw.ustring.gsub(input,find,replace)&lt;br /&gt;
    ---- I have no idea why {{x gets returned as [[:Template:x but I don&amp;#039;t like it.&lt;br /&gt;
   --input=mw.ustring.gsub(input,[=[%[%[:Template:]=]..&amp;quot;(.-)&amp;quot;..[=[%]%]]=],&amp;quot;{{%1}}&amp;quot;)&lt;br /&gt;
   -- no good - it still loses all the parameters out of all the templates!&lt;br /&gt;
   return frame.preprocess(frame, &amp;quot;&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&amp;quot; .. input .. [[&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;]])&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;br /&gt;
&lt;br /&gt;
-- I wonder if there&amp;#039;s a way to put this directly back into an open edit window...&lt;/div&gt;</summary>
		<author><name>imported&gt;Wnt</name></author>
	</entry>
</feed>