<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://battleint.net/index.php?action=history&amp;feed=atom&amp;title=Module%3AUstring%2Fdoc</id>
	<title>Module:Ustring/doc - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://battleint.net/index.php?action=history&amp;feed=atom&amp;title=Module%3AUstring%2Fdoc"/>
	<link rel="alternate" type="text/html" href="https://battleint.net/index.php?title=Module:Ustring/doc&amp;action=history"/>
	<updated>2026-04-25T17:46:52Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.44.0</generator>
	<entry>
		<id>https://battleint.net/index.php?title=Module:Ustring/doc&amp;diff=177082&amp;oldid=prev</id>
		<title>imported&gt;Deadfire: Template Doc Creation</title>
		<link rel="alternate" type="text/html" href="https://battleint.net/index.php?title=Module:Ustring/doc&amp;diff=177082&amp;oldid=prev"/>
		<updated>2023-06-03T00:20:14Z</updated>

		<summary type="html">&lt;p&gt;Template Doc Creation&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) --&amp;gt;&lt;br /&gt;
This module directly imports all functions from the {{luaref|Ustring library|mw.ustring}} library. Documentation for each function can be found there.&lt;br /&gt;
&lt;br /&gt;
The module takes an indefinite number of arguments. Arguments given as {{para|s1}}, {{para|s2}}, etc, are read first, and are used as strings. All remaining numerical arguments are coerced to number type if possible, and remain strings if not. If you wish for a numerical (i.e. unnamed or &amp;quot;{{para|1}}&amp;quot;, &amp;quot;{{para|2}}&amp;quot;) to remain a string, you can simply escape it by inserting &amp;lt;code&amp;gt;\&amp;lt;/code&amp;gt; at the beginning of the string.&lt;br /&gt;
&lt;br /&gt;
Note that MediaWiki will always trim whitespace from named arguments; to give arguments with surrounding whitespace you must use unnamed parameters starting with &amp;lt;code&amp;gt;\&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ How to pass inconvenient strings&lt;br /&gt;
|-&lt;br /&gt;
! To pass this... !! Write this !! Explanation&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;quot;  0123  &amp;quot;&amp;lt;/code&amp;gt; || {{para||\  123  }} || To get surrounding whitespace must use unnamed, but must precede with &amp;lt;code&amp;gt;\&amp;lt;/code&amp;gt; to indicate that it isn&amp;#039;t a number.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;quot;0123&amp;quot;&amp;lt;/code&amp;gt; || {{para|s1|0123}} || If you don&amp;#039;t need to preserve whitespace use {{para|s1}} etc.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;quot;0123&amp;quot;&amp;lt;/code&amp;gt; || {{para|1|\0123}} || If you don&amp;#039;t need to preserve whitespace explicitly use {{para|1}} etc.&lt;br /&gt;
|-&lt;br /&gt;
| In another template, to pass its parameter &amp;lt;code&amp;gt;{{{1}}}&amp;lt;/code&amp;gt;, preserving whitespace || {{para||\{{{1}}}}} || Must provide the &amp;lt;code&amp;gt;\&amp;lt;/code&amp;gt; with unknown string input.&lt;br /&gt;
|-&lt;br /&gt;
| In another template, to pass its parameter &amp;lt;code&amp;gt;{{{1}}}&amp;lt;/code&amp;gt;, stripping whitespace || {{para|s1|{{{1}}}}} || &lt;br /&gt;
|-&lt;br /&gt;
| In another template, to pass its parameter &amp;lt;code&amp;gt;{{{1}}}&amp;lt;/code&amp;gt;, stripping whitespace || {{para|1|&amp;lt;nowiki&amp;gt;\{{#if:1|{{{1}}}}}&amp;lt;/nowiki&amp;gt;}} || &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
You can also wrap results in tags. All other unused arguments will be passed to {{luaref|frame:extensionTag}}&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{&amp;lt;/nowiki&amp;gt;#invoke:{{BASEPAGENAME}}|&amp;#039;&amp;#039;function_name&amp;#039;&amp;#039;|arg1|arg2|...}}&amp;lt;/code&amp;gt; is equivalent to {{luaref|Ustring library|mw.ustring.&amp;#039;&amp;#039;function_name&amp;#039;&amp;#039;|args=arg1, arg2, ...}}&lt;br /&gt;
&lt;br /&gt;
===Example using mw.ustring.sub===&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#invoke:Ustring|sub|s1=abcde|2|4}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
produces:&lt;br /&gt;
&lt;br /&gt;
{{#invoke:Ustring|sub|s1=abcde|2|4}}&lt;br /&gt;
&lt;br /&gt;
===Example using mw.ustring.gsub===&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#invoke:Ustring|gsub|s1=1234|23|}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
produces:&lt;br /&gt;
&lt;br /&gt;
{{#invoke:Ustring|gsub|s1=1234|23|}}&lt;br /&gt;
&lt;br /&gt;
===Example using mw.ustring.char===&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;amp;amp;amp;#{{#invoke:ustring|char|49|48|59}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
produces:&lt;br /&gt;
&lt;br /&gt;
&amp;amp;amp;#{{#invoke:ustring|char|49|48|59}}&lt;br /&gt;
&lt;br /&gt;
===Example using mw.ustring.match===&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#invoke:Ustring|match|s1=abcde|s2=(c%w)}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
produces:&lt;br /&gt;
&lt;br /&gt;
{{#invoke:Ustring|match|s1=abcde|s2=(c%w)}}&lt;br /&gt;
&lt;br /&gt;
Note: Only the first match is returned. Additional returns are omitted because mw.ustring.gsub&amp;#039;s second return value is generally undesirable.&lt;br /&gt;
&lt;br /&gt;
===Example using tag arguments===&lt;br /&gt;
&amp;lt;pre&amp;gt;{{#invoke:Ustring|match&lt;br /&gt;
|s1={{Module:Ustring}}|%s%s%sif%snot%s[^%s]+%sthen.+%&lt;br /&gt;
&amp;lt;!--enter an actual newline character to match &amp;#039;\n&amp;#039;--&amp;gt;%s%s%send&lt;br /&gt;
|tag=syntaxhighlight|lang=lua}}&amp;lt;/pre&amp;gt;&lt;br /&gt;
produces:&lt;br /&gt;
{{#invoke:Ustring|match&lt;br /&gt;
|s1={{Module:Ustring}}|%s%s%sif%snot%s[^%s]+%sthen.+%&lt;br /&gt;
&amp;lt;!--enter an actual newline character to match &amp;#039;\n&amp;#039;--&amp;gt;%s%s%send&lt;br /&gt;
|tag=syntaxhighlight|lang=lua}}&lt;br /&gt;
&lt;br /&gt;
Note that:&lt;br /&gt;
{{#tag:pre|&amp;lt;nowiki&amp;gt;&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;{{#invoke:Ustring|match&lt;br /&gt;
|s1={{Module:Ustring}}|%s%s%sif%snot%s[^%s]+%sthen.+%&lt;br /&gt;
&amp;lt;!--enter an actual newline character to match &amp;#039;\n&amp;#039;--&amp;gt;%s%s%send}}&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
produces:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;{{#invoke:Ustring|match&lt;br /&gt;
|s1={{Module:Ustring}}|%s%s%sif%snot%s[^%s]+%sthen.+%&lt;br /&gt;
&amp;lt;!--enter an actual newline character to match &amp;#039;\n&amp;#039;--&amp;gt;%s%s%send}}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Errors ==&lt;br /&gt;
Errors from accessing {{luaref|Ustring library|mw.ustring}} should be maintained, e.g.:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#invoke:Ustring|xyzzy}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
should produce:&lt;br /&gt;
&lt;br /&gt;
{{script error|Script error: The function &amp;quot;xyzzy&amp;quot; does not exist.}}&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#invoke:Ustring|maxPatternLength}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
should produce:&lt;br /&gt;
&lt;br /&gt;
{{script error|Script error: &amp;quot;maxPatternLength&amp;quot; is not a function.}}&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
{{String handling templates}}&lt;br /&gt;
&amp;lt;includeonly&amp;gt;{{#ifeq:{{SUBPAGENAME}}|sandbox | |&lt;br /&gt;
&amp;lt;!-- Categories below this line, please; interwikis at Wikidata --&amp;gt;&lt;br /&gt;
[[Category:Modules that manipulate strings|*]]&lt;br /&gt;
}}&amp;lt;/includeonly&amp;gt;&lt;/div&gt;</summary>
		<author><name>imported&gt;Deadfire</name></author>
	</entry>
</feed>