<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://themidnight.wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3AMultiReplace</id>
	<title>Module:MultiReplace - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://themidnight.wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3AMultiReplace"/>
	<link rel="alternate" type="text/html" href="https://themidnight.wiki/index.php?title=Module:MultiReplace&amp;action=history"/>
	<updated>2026-04-03T18:09:46Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.1</generator>
	<entry>
		<id>https://themidnight.wiki/index.php?title=Module:MultiReplace&amp;diff=6241&amp;oldid=prev</id>
		<title>Timothy: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://themidnight.wiki/index.php?title=Module:MultiReplace&amp;diff=6241&amp;oldid=prev"/>
		<updated>2023-05-29T03:08:46Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 23:08, 28 May 2023&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Timothy</name></author>
	</entry>
	<entry>
		<id>https://themidnight.wiki/index.php?title=Module:MultiReplace&amp;diff=6240&amp;oldid=prev</id>
		<title>wikipedia&gt;Pppery: Per edit request</title>
		<link rel="alternate" type="text/html" href="https://themidnight.wiki/index.php?title=Module:MultiReplace&amp;diff=6240&amp;oldid=prev"/>
		<updated>2022-11-15T20:58:00Z</updated>

		<summary type="html">&lt;p&gt;Per edit request&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local p = {}&lt;br /&gt;
&lt;br /&gt;
local function MultiReplace(args)&lt;br /&gt;
	local input = args[1] or &amp;quot;{{{1}}}&amp;quot;&lt;br /&gt;
	local plain = args.plain == &amp;quot;yes&amp;quot;&lt;br /&gt;
&lt;br /&gt;
	local i = 1&lt;br /&gt;
	local changeList = {}&lt;br /&gt;
	while args[i * 2] do&lt;br /&gt;
		local change = {pattern = args[i * 2], repl = args[i * 2 + 1]}&lt;br /&gt;
		if not change.repl then&lt;br /&gt;
			return require(&amp;#039;Module:Error&amp;#039;).error{&lt;br /&gt;
				&amp;#039;MultiReplace: Unpaired argument: &amp;lt;code&amp;gt;&amp;#039; .. (i * 2) .. &amp;#039; = &amp;#039; .. mw.text.nowiki(change.pattern) .. &amp;#039;&amp;lt;/code&amp;gt;&amp;#039;&lt;br /&gt;
			}&lt;br /&gt;
		end&lt;br /&gt;
		changeList[i] = change&lt;br /&gt;
		i = i + 1&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local matchList = {}&lt;br /&gt;
	local pos = 1&lt;br /&gt;
	local len = mw.ustring.len(input)&lt;br /&gt;
	local result = &amp;quot;&amp;quot;&lt;br /&gt;
	while pos &amp;lt;= len do&lt;br /&gt;
		local bestStart = len + 1&lt;br /&gt;
		local bestStop = len&lt;br /&gt;
		local bestChange&lt;br /&gt;
		for _, change in ipairs(changeList) do&lt;br /&gt;
			local start, stop = mw.ustring.find(input, change.pattern, pos, plain)&lt;br /&gt;
			if start and (start &amp;lt; bestStart) then&lt;br /&gt;
				bestStart = start&lt;br /&gt;
				bestStop = stop&lt;br /&gt;
				bestChange = change&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		result = result .. mw.ustring.sub(input, pos, bestStart - 1)&lt;br /&gt;
		if bestChange then&lt;br /&gt;
			local fragment = mw.ustring.sub(input, bestStart, bestStop)&lt;br /&gt;
			result = result .. (plain and bestChange.repl or&lt;br /&gt;
				mw.ustring.gsub(fragment, bestChange.pattern, bestChange.repl, 1))&lt;br /&gt;
		end&lt;br /&gt;
		pos = bestStop + 1&lt;br /&gt;
	end&lt;br /&gt;
	return result&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.main(frame, ...)&lt;br /&gt;
	local args =&lt;br /&gt;
		type(frame) ~= &amp;#039;table&amp;#039; and {frame, ...} or&lt;br /&gt;
		type(frame.args) ~= &amp;#039;table&amp;#039; and frame or&lt;br /&gt;
		frame.args[1] and frame.args or&lt;br /&gt;
		frame:getParent().args&lt;br /&gt;
	return MultiReplace(args)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>wikipedia&gt;Pppery</name></author>
	</entry>
</feed>