<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ja">
	<id>https://bsd.neuroinf.jp/w/index.php?action=history&amp;feed=atom&amp;title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB%3AStringReplace</id>
	<title>モジュール:StringReplace - 版の履歴</title>
	<link rel="self" type="application/atom+xml" href="https://bsd.neuroinf.jp/w/index.php?action=history&amp;feed=atom&amp;title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB%3AStringReplace"/>
	<link rel="alternate" type="text/html" href="https://bsd.neuroinf.jp/w/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB:StringReplace&amp;action=history"/>
	<updated>2026-04-17T12:00:09Z</updated>
	<subtitle>このウィキのこのページに関する変更履歴</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://bsd.neuroinf.jp/w/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB:StringReplace&amp;diff=37220&amp;oldid=prev</id>
		<title>WikiSysop: 1版</title>
		<link rel="alternate" type="text/html" href="https://bsd.neuroinf.jp/w/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB:StringReplace&amp;diff=37220&amp;oldid=prev"/>
		<updated>2017-01-19T02:20:43Z</updated>

		<summary type="html">&lt;p&gt;1版&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新規ページ&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>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://bsd.neuroinf.jp/w/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB:StringReplace&amp;diff=27192&amp;oldid=prev</id>
		<title>WikiSysop: 1版</title>
		<link rel="alternate" type="text/html" href="https://bsd.neuroinf.jp/w/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB:StringReplace&amp;diff=27192&amp;oldid=prev"/>
		<updated>2014-06-11T14:56:56Z</updated>

		<summary type="html">&lt;p&gt;1版&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新規ページ&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>WikiSysop</name></author>
	</entry>
</feed>