<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://chabadpedia.com/index.php?action=history&amp;feed=atom&amp;title=Module%3AStringTools</id>
	<title>Module:StringTools - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://chabadpedia.com/index.php?action=history&amp;feed=atom&amp;title=Module%3AStringTools"/>
	<link rel="alternate" type="text/html" href="https://chabadpedia.com/index.php?title=Module:StringTools&amp;action=history"/>
	<updated>2026-04-27T11:21:00Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>https://chabadpedia.com/index.php?title=Module:StringTools&amp;diff=5383&amp;oldid=prev</id>
		<title>Shia.k: Created page with &quot;local p = {}  --[=[ 	Similar to gmatch, but it returns the count of the match in addition to the 	list of captures, something like ipairs(). 	 	If the pattern doesn&#039;t contain any captures, the whole match is returned. 	 	Invoke thus: 	 		for i, whole_match in require(&quot;Module:string&quot;).imatch(text, pattern) do 			[ do something with i and whole_match ] 		end 	 	or 	 		for i, capture1[, capture2[, capture3[, ...]]] in require(&quot;Module:string&quot;).imatch(text, pattern) do 			[ d...&quot;</title>
		<link rel="alternate" type="text/html" href="https://chabadpedia.com/index.php?title=Module:StringTools&amp;diff=5383&amp;oldid=prev"/>
		<updated>2025-03-19T21:14:09Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;local p = {}  --[=[ 	Similar to gmatch, but it returns the count of the match in addition to the 	list of captures, something like ipairs(). 	 	If the pattern doesn&amp;#039;t contain any captures, the whole match is returned. 	 	Invoke thus: 	 		for i, whole_match in require(&amp;quot;Module:string&amp;quot;).imatch(text, pattern) do 			[ do something with i and whole_match ] 		end 	 	or 	 		for i, capture1[, capture2[, capture3[, ...]]] in require(&amp;quot;Module:string&amp;quot;).imatch(text, pattern) do 			[ d...&amp;quot;&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;
	Similar to gmatch, but it returns the count of the match in addition to the&lt;br /&gt;
	list of captures, something like ipairs().&lt;br /&gt;
	&lt;br /&gt;
	If the pattern doesn&amp;#039;t contain any captures, the whole match is returned.&lt;br /&gt;
	&lt;br /&gt;
	Invoke thus:&lt;br /&gt;
	&lt;br /&gt;
		for i, whole_match in require(&amp;quot;Module:string&amp;quot;).imatch(text, pattern) do&lt;br /&gt;
			[ do something with i and whole_match ]&lt;br /&gt;
		end&lt;br /&gt;
	&lt;br /&gt;
	or&lt;br /&gt;
	&lt;br /&gt;
		for i, capture1[, capture2[, capture3[, ...]]] in require(&amp;quot;Module:string&amp;quot;).imatch(text, pattern) do&lt;br /&gt;
			[ do something with i and capture1 ]&lt;br /&gt;
		end&lt;br /&gt;
]=]&lt;br /&gt;
&lt;br /&gt;
function p.imatch(text, pattern, start, plain)&lt;br /&gt;
	local i = 0&lt;br /&gt;
	local pos = start or 0&lt;br /&gt;
	if not mw.ustring.find(pattern, &amp;quot;%b()&amp;quot;) then&lt;br /&gt;
		pattern = &amp;quot;(&amp;quot; .. pattern .. &amp;quot;)&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
	return function()&lt;br /&gt;
		i = i + 1&lt;br /&gt;
		local return_values = { mw.ustring.find(text, pattern, pos, plain) }&lt;br /&gt;
		local j = return_values[2]&lt;br /&gt;
		&lt;br /&gt;
		if #return_values &amp;gt; 0 then&lt;br /&gt;
			pos = j + 1&lt;br /&gt;
			-- Skip the first two returned values, which are the indices of the&lt;br /&gt;
			-- whole match.&lt;br /&gt;
			return i, unpack(return_values, 3)&lt;br /&gt;
		else&lt;br /&gt;
			return nil, nil&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Shia.k</name></author>
	</entry>
</feed>