<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.americanmusicclub.com/index.php?action=history&amp;feed=atom&amp;title=Module%3AStringReplace</id>
	<title>Module:StringReplace - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.americanmusicclub.com/index.php?action=history&amp;feed=atom&amp;title=Module%3AStringReplace"/>
	<link rel="alternate" type="text/html" href="https://wiki.americanmusicclub.com/index.php?title=Module:StringReplace&amp;action=history"/>
	<updated>2026-04-06T14:12:33Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.7</generator>
	<entry>
		<id>https://wiki.americanmusicclub.com/index.php?title=Module:StringReplace&amp;diff=26568&amp;oldid=prev</id>
		<title>Amc-admin: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://wiki.americanmusicclub.com/index.php?title=Module:StringReplace&amp;diff=26568&amp;oldid=prev"/>
		<updated>2016-11-25T13:54:20Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-- Module for different search and replace operations on strings.&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
-- Takes one string parameter, and returns the string with all characters with special meaning for Lua patterns escaped with a preceding `%`.&lt;br /&gt;
function p.escape_pattern(text)&lt;br /&gt;
    -- Replaces each occurrence of any of ().%+-*?[^$ with a `%` and then the character.&lt;br /&gt;
    local r = string.gsub(text, &amp;quot;[%(%)%.%%%+%-%*%?%[%^%$]&amp;quot;, &amp;quot;%%%1&amp;quot;)&lt;br /&gt;
    return r&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Returns the first parameter, with all occurrences of the second parameter replaced with the third parameter.&lt;br /&gt;
-- All special characters are ignored: {{#invoke:StringReplace|replace_all|test.a%1$foo|%1|bar}} results in `test.abarfoo`.&lt;br /&gt;
function p.replace_all(frame)&lt;br /&gt;
    local str = frame.args[1]&lt;br /&gt;
    local strToFind = frame.args[2]&lt;br /&gt;
    local strToreplaceWith = frame.args[3]&lt;br /&gt;
    local r = string.gsub(str, p.escape_pattern(strToFind), p.escape_pattern(strToreplaceWith))&lt;br /&gt;
    return r&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
p[&amp;#039;encode wiki page name&amp;#039;] = function( frame )&lt;br /&gt;
	local x = mw.ustring.gsub( &lt;br /&gt;
		frame.args[1] or &amp;#039;&amp;#039;, &lt;br /&gt;
		&amp;#039;[\&amp;#039;&amp;quot;&amp;amp;_]&amp;#039;, &lt;br /&gt;
		{ &lt;br /&gt;
			[&amp;quot;&amp;#039;&amp;quot;] = &amp;#039;&amp;amp;#39;&amp;#039;, &lt;br /&gt;
			[&amp;#039;&amp;quot;&amp;#039;] = &amp;#039;&amp;amp;#34;&amp;#039;, &lt;br /&gt;
			[&amp;#039;&amp;amp;&amp;#039;] = &amp;#039;&amp;amp;#38;&amp;#039;, &lt;br /&gt;
			[&amp;#039;_&amp;#039;] = &amp;#039; &amp;#039;, &lt;br /&gt;
		} &lt;br /&gt;
	)&lt;br /&gt;
	return mw.text.trim( x )&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Amc-admin</name></author>
	</entry>
</feed>