<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3ASandbox%2FUser%3ASsola</id>
	<title>Module:Sandbox/User:Ssola - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3ASandbox%2FUser%3ASsola"/>
	<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Sandbox/User:Ssola&amp;action=history"/>
	<updated>2026-04-21T19:21:28Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://stockhub.co/index.php?title=Module:Sandbox/User:Ssola&amp;diff=146357&amp;oldid=prev</id>
		<title>imported&gt;Ssola: ←Created page with &#039;local p = {}  --[[ Split  This function Splits a string based on a pattern, returns nth substring based on count.  Usage: {{#invoke:StringFunc|split|source_strin...&#039;</title>
		<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Sandbox/User:Ssola&amp;diff=146357&amp;oldid=prev"/>
		<updated>2016-01-30T18:32:35Z</updated>

		<summary type="html">&lt;p&gt;&lt;a href=&quot;/index.php?title=WP:AES&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;WP:AES (page does not exist)&quot;&gt;←&lt;/a&gt;Created page with &amp;#039;local p = {}  --[[ Split  This function Splits a string based on a pattern, returns nth substring based on count.  Usage: {{#invoke:StringFunc|split|source_strin...&amp;#039;&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;
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, {&amp;#039;source&amp;#039;, &amp;#039;pattern&amp;#039;, &amp;#039;count&amp;#039;, &amp;#039;plain&amp;#039;} )&lt;br /&gt;
	local source_str = new_args[&amp;#039;source&amp;#039;] or &amp;#039;&amp;#039;;&lt;br /&gt;
	local pattern = new_args[&amp;#039;pattern&amp;#039;] or &amp;#039;&amp;#039;;&lt;br /&gt;
	if source_str == &amp;#039;&amp;#039; or pattern == &amp;#039;&amp;#039; then&lt;br /&gt;
		return source_str;&lt;br /&gt;
	end&lt;br /&gt;
	local l_plain = p._getBoolean( new_args[&amp;#039;plain&amp;#039;] or true );&lt;br /&gt;
	if l_plain then&lt;br /&gt;
		pattern = p._escapePattern( pattern );&lt;br /&gt;
	end&lt;br /&gt;
	local plain = false;&lt;br /&gt;
	pattern = &amp;quot;[&amp;quot; .. pattern .. &amp;quot;]&amp;quot; &lt;br /&gt;
	local ret_count = tonumber( new_args[&amp;#039;count&amp;#039;] ) or 1;&lt;br /&gt;
	local start = 1;&lt;br /&gt;
	local iter = mw.ustring.find(source_str, pattern, start, plain);&lt;br /&gt;
	if iter == nil then&lt;br /&gt;
		return source_str;&lt;br /&gt;
	end&lt;br /&gt;
	if ret_count == 1 then&lt;br /&gt;
		return mw.ustring.sub( source_str, start, iter);&lt;br /&gt;
	end&lt;br /&gt;
    for i=2, ret_count do&lt;br /&gt;
    	start = iter+1;&lt;br /&gt;
    	iter = mw.ustring.find(source_str,  pattern, start, plain);&lt;br /&gt;
    	if iter == nil then&lt;br /&gt;
    		break &lt;br /&gt;
    	end&lt;br /&gt;
    end&lt;br /&gt;
    return mw.ustring.sub( source_str,start,iter); &lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Argument list helper function, as per Module:String&lt;br /&gt;
function p._getParameters( frame_args, arg_list)&lt;br /&gt;
	local new_args = {};&lt;br /&gt;
	local index = 1;&lt;br /&gt;
	local value;&lt;br /&gt;
	for i, arg in ipairs( arg_list ) do&lt;br /&gt;
		value = frame_args[arg]&lt;br /&gt;
		if value == nil then&lt;br /&gt;
			value = frame_args[index];&lt;br /&gt;
			index = index + 1;&lt;br /&gt;
		end&lt;br /&gt;
		new_args[arg] = value;&lt;br /&gt;
	end&lt;br /&gt;
	return new_args;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Escape Pattern helper function so that all charecters 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;
function p._getBoolean( boolean_str ) &lt;br /&gt;
	local boolean_value;&lt;br /&gt;
	&lt;br /&gt;
	if type( boolean_str ) == &amp;#039;string&amp;#039; then&lt;br /&gt;
		boolean_str = boolean_str:lower();&lt;br /&gt;
		if boolean_str == &amp;#039;false&amp;#039; or boolean_str == &amp;#039;no&amp;#039; or boolean_str == &amp;#039;O&amp;#039; or boolean_str == &amp;#039;&amp;#039; then&lt;br /&gt;
			boolean_value = false;&lt;br /&gt;
		else&lt;br /&gt;
			boolean_value = true;&lt;br /&gt;
		end&lt;br /&gt;
	elseif type(boolean_str) == &amp;#039;boolean&amp;#039; then&lt;br /&gt;
			boolean_value = boolean_str;&lt;br /&gt;
	else&lt;br /&gt;
		error( &amp;#039;No boolean value found&amp;#039; );&lt;br /&gt;
	end&lt;br /&gt;
	return boolean_value&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>imported&gt;Ssola</name></author>
	</entry>
</feed>