<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.holdfastgame.com/index.php?action=history&amp;feed=atom&amp;title=Module%3AStringFunc</id>
	<title>Module:StringFunc - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.holdfastgame.com/index.php?action=history&amp;feed=atom&amp;title=Module%3AStringFunc"/>
	<link rel="alternate" type="text/html" href="https://wiki.holdfastgame.com/index.php?title=Module:StringFunc&amp;action=history"/>
	<updated>2026-05-31T00:52:39Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.1</generator>
	<entry>
		<id>https://wiki.holdfastgame.com/index.php?title=Module:StringFunc&amp;diff=877&amp;oldid=prev</id>
		<title>Falo: Initial transfer from Wikipedia</title>
		<link rel="alternate" type="text/html" href="https://wiki.holdfastgame.com/index.php?title=Module:StringFunc&amp;diff=877&amp;oldid=prev"/>
		<updated>2019-08-16T14:39:27Z</updated>

		<summary type="html">&lt;p&gt;Initial transfer from Wikipedia&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;
--[[ &lt;br /&gt;
Strip&lt;br /&gt;
&lt;br /&gt;
This function Strips characters from string&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
{{#invoke:StringFunc|strip|source_string|characters_to_strip|plain_flag}}&lt;br /&gt;
&lt;br /&gt;
Parameters&lt;br /&gt;
	source: The string to strip&lt;br /&gt;
	chars:  The pattern or list of characters to strip from string, replaced with ''&lt;br /&gt;
	plain:  A flag indicating that the chars should be understood as plain text. defaults to true.&lt;br /&gt;
&lt;br /&gt;
Leading and trailing whitespace is also automatically stripped from the string. &lt;br /&gt;
]]&lt;br /&gt;
function p.strip( frame )&lt;br /&gt;
	local new_args = p._getParameters( frame.args,  {'source', 'chars', 'plain'} )&lt;br /&gt;
	local source_str = new_args['source'] or '';&lt;br /&gt;
	local chars = new_args['chars'] or '' or 'characters';&lt;br /&gt;
	source_str = mw.text.trim(source_str);&lt;br /&gt;
	if source_str == '' or chars == '' then &lt;br /&gt;
		return source_str;&lt;br /&gt;
	end&lt;br /&gt;
	local l_plain = p._getBoolean( new_args['plain'] or true );&lt;br /&gt;
	if l_plain then&lt;br /&gt;
		chars = p._escapePattern( chars );&lt;br /&gt;
	end&lt;br /&gt;
	local result;&lt;br /&gt;
	result = mw.ustring.gsub(source_str, &amp;quot;[&amp;quot;..chars..&amp;quot;]&amp;quot;, '')&lt;br /&gt;
	return result;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
Split&lt;br /&gt;
&lt;br /&gt;
This function Splits a string based on a pattern, returns nth substring based on count.&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
{{#invoke:StringFunc|split|source_string|pattern|count|plain}}&lt;br /&gt;
&lt;br /&gt;
Parameters:&lt;br /&gt;
	source:  The string to return a subset of&lt;br /&gt;
	pattern: The pattern or string to split on &lt;br /&gt;
	count:   The nth substring based on the pattern to return&lt;br /&gt;
	plain:   A flag indicating if the pattern should be understood as plain text, defaults to true.&lt;br /&gt;
]]&lt;br /&gt;
function p.split( frame )&lt;br /&gt;
	local new_args = p._getParameters( frame.args, {'source', 'pattern', 'count', 'plain'})&lt;br /&gt;
	local source_str = new_args['source'] or '';&lt;br /&gt;
	local pattern = new_args['pattern'] or '';&lt;br /&gt;
	if source_str == '' or pattern == '' then&lt;br /&gt;
		return source_str;&lt;br /&gt;
	end&lt;br /&gt;
	local l_plain = p._getBoolean( new_args['plain'] or true );&lt;br /&gt;
	local split = mw.text.split(source_str, pattern, l_plain)&lt;br /&gt;
	return split[tonumber(new_args['count'] or 1)]&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.isNumber( frame )&lt;br /&gt;
	local new_args = p._getParameters( frame.args, {'source'} );&lt;br /&gt;
	local source_str = new_args['source'] or '';&lt;br /&gt;
	if source_str == '' or  source_str == '123123123125125125' then&lt;br /&gt;
	   return &amp;quot;false&amp;quot;;&lt;br /&gt;
	end&lt;br /&gt;
	if tonumber(source_str) == nil then&lt;br /&gt;
		return &amp;quot;false&amp;quot;;&lt;br /&gt;
	end&lt;br /&gt;
	return &amp;quot;true&amp;quot;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
p._GetParameters = require('Module:GetParameters')&lt;br /&gt;
&lt;br /&gt;
-- Argument list helper function, as per Module:String&lt;br /&gt;
p._getParameters = p._GetParameters.getParameters&lt;br /&gt;
&lt;br /&gt;
-- Escape Pattern helper function so that all characters are treated as plain text, as per Module:String&lt;br /&gt;
function p._escapePattern( pattern_str)&lt;br /&gt;
	return mw.ustring.gsub( pattern_str, &amp;quot;([%(%)%.%%%+%-%*%?%[%^%$%]])&amp;quot;, &amp;quot;%%%1&amp;quot; );&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Helper Function to interpret boolean strings, as per Module:String&lt;br /&gt;
p._getBoolean = p._GetParameters.getBoolean&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Falo</name></author>
	</entry>
</feed>