<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="fa">
	<id>https://www.islamical.org/w/index.php?action=history&amp;feed=atom&amp;title=%D9%BE%D9%88%D8%AF%D9%85%D8%A7%D9%86%3AFind_country_names_in_string</id>
	<title>پودمان:Find country names in string - تاریخچهٔ نسخه‌ها</title>
	<link rel="self" type="application/atom+xml" href="https://www.islamical.org/w/index.php?action=history&amp;feed=atom&amp;title=%D9%BE%D9%88%D8%AF%D9%85%D8%A7%D9%86%3AFind_country_names_in_string"/>
	<link rel="alternate" type="text/html" href="https://www.islamical.org/w/index.php?title=%D9%BE%D9%88%D8%AF%D9%85%D8%A7%D9%86:Find_country_names_in_string&amp;action=history"/>
	<updated>2026-06-23T14:39:41Z</updated>
	<subtitle>تاریخچهٔ نسخه‌ها برای این صفحه در ویکی</subtitle>
	<generator>MediaWiki 1.41.1</generator>
	<entry>
		<id>https://www.islamical.org/w/index.php?title=%D9%BE%D9%88%D8%AF%D9%85%D8%A7%D9%86:Find_country_names_in_string&amp;diff=105892&amp;oldid=prev</id>
		<title>Shahroudi: +</title>
		<link rel="alternate" type="text/html" href="https://www.islamical.org/w/index.php?title=%D9%BE%D9%88%D8%AF%D9%85%D8%A7%D9%86:Find_country_names_in_string&amp;diff=105892&amp;oldid=prev"/>
		<updated>2025-02-19T02:45:04Z</updated>

		<summary type="html">&lt;p&gt;+&lt;/p&gt;
&lt;p&gt;&lt;b&gt;صفحهٔ تازه&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local p = {}&lt;br /&gt;
local getArgs = require(&amp;#039;Module:Arguments&amp;#039;).getArgs&lt;br /&gt;
local yesno = require(&amp;#039;Module:Yesno&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
local countries = require(&amp;#039;Module:Find country names in string/countries&amp;#039;).countries&lt;br /&gt;
local frame = mw.getCurrentFrame()&lt;br /&gt;
&lt;br /&gt;
-- Escapes spaces in a string&lt;br /&gt;
-- Used to find exact country names in input&lt;br /&gt;
-- i.e. !&amp;quot;mali&amp;quot; in &amp;quot;somalia&amp;quot; or !&amp;quot;Congo&amp;quot; in &amp;quot;Democratic Republic of Congo&amp;quot;&lt;br /&gt;
function replace_spaces (s)&lt;br /&gt;
	s = mw.ustring.gsub(s, &amp;#039;%s&amp;#039;, &amp;#039;%%s&amp;#039;)&lt;br /&gt;
	--s = &amp;#039;%^&amp;#039; .. s .. &amp;#039;%$&amp;#039;&lt;br /&gt;
	return s&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p._isRedirect(title)&lt;br /&gt;
	return mw.title.getCurrentTitle(title).isRedirect&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Lists all wikilinked country names in /valid countries subpage (content mode should be converted to wikitext)&lt;br /&gt;
function p.doc(frame)&lt;br /&gt;
	local text = &amp;#039;فهرست نام معتبر کشورها که توسط این الگو شناسایی می‌شوند به شرح زیر است.&amp;#039; ..&lt;br /&gt;
		 &amp;#039;\n\nدر صورتی که عنوان مقالهٔ مورد تأیید این الگو تغییر کرده باشد (به صفحهٔ دیگری تغییرمسیر یافته باشد)،&amp;#039; ..&lt;br /&gt;
		 &amp;#039; نماد تغییرمسیر در جلوی نام آن کشور نمایش می‌یابد. در این صورت لازم است که [[&amp;#039; ..&lt;br /&gt;
		 &amp;#039;پودمان:Find country names in string/countries]] ویرایش شود و نام آن کشور در آن به‌روزرسانی شود.&amp;#039; ..&lt;br /&gt;
		 &amp;#039;\n\nدر صورتی که قادر به ویرایش این پودمان نیستید، لطفاً در بحث پودمان یا در [&amp;#039; .. &amp;#039;[ویکی‌پدیا:قهوه‌خانه/فنی]]&amp;#039; ..&lt;br /&gt;
		 &amp;#039; درخواست دهید تا ویرایش مورد نظر در پودمان انجام شود.&amp;#039; ..&lt;br /&gt;
		 &amp;#039;\n\nدقت کنید که در صورت تغییر عنوان مقالهٔ یک کشور، باید رده‌های مرتبط با آن کشور نیز به عنوان جدید منتقل شوند.&amp;#039; ..&lt;br /&gt;
		 &amp;#039; بنابراین پس از ایجاد تغییر در پودمان عنوان رده‌ها را نیز اصلاح کنید تا از بروز خطا در صفحهٔ آن رده‌ها جلوگیری شود.\n&amp;#039;&lt;br /&gt;
	local li, ob, cb, nl, sp, i = &amp;#039;* &amp;#039;, &amp;#039;[[&amp;#039;, &amp;#039;]]&amp;#039;, &amp;#039;\n&amp;#039;, &amp;#039; &amp;#039;, 1&lt;br /&gt;
	local redirect_icon, list = &amp;#039;{&amp;#039; .. &amp;#039;{آیکون|تغییرمسیر}}&amp;#039;, frame:expandTemplate{title = &amp;#039;چندستونه&amp;#039;, args = {&amp;#039;4&amp;#039;}}&lt;br /&gt;
	while (i &amp;lt;= #countries) do&lt;br /&gt;
		list = list .. nl .. li .. ob .. countries[i] .. (p._isRedirect(countries[i]) and cb .. sp .. redirect_icon or cb)&lt;br /&gt;
		i = i + 1&lt;br /&gt;
	end&lt;br /&gt;
	text =  text .. list&lt;br /&gt;
			&lt;br /&gt;
	return text&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
	local args = getArgs(frame, {&lt;br /&gt;
		valueFunc = function (key, value)										-- Do not trim whitespace from separator parameter (args[3])&lt;br /&gt;
			if key == 3 then&lt;br /&gt;
				return value&lt;br /&gt;
			elseif value then&lt;br /&gt;
				value = mw.text.trim(value)&lt;br /&gt;
				if value ~= &amp;#039;&amp;#039; then&lt;br /&gt;
					return value&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			return nil&lt;br /&gt;
		end&lt;br /&gt;
	})&lt;br /&gt;
	return p._main(args)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p._main(args)&lt;br /&gt;
	local args = frame:getParent().args&lt;br /&gt;
	local arg = args[1] or 1													-- Use args[1] (must be and integer) as the index of the country name to return,&lt;br /&gt;
	local tracking = {}&lt;br /&gt;
																				-- and if args[1] is not provided, return the first country name&lt;br /&gt;
	&lt;br /&gt;
	local input = args[2] or mw.title.getCurrentTitle().text					-- Input can be a string in args[2] and if not provided, will be the page name&lt;br /&gt;
	local j = 1&lt;br /&gt;
	local names = {}															-- Table to store country names in alphabetical order&lt;br /&gt;
	if yesno(args[&amp;#039;روابط&amp;#039;]) then &lt;br /&gt;
		local match_num = 0&lt;br /&gt;
		repeat&lt;br /&gt;
			local c1_found = false&lt;br /&gt;
			local c2_found = false&lt;br /&gt;
			local country1 = &amp;#039;&amp;#039;&lt;br /&gt;
			local country2 = &amp;#039;&amp;#039;&lt;br /&gt;
			if (match_num == 0) then&lt;br /&gt;
				country1, country2 = mw.ustring.match(input, &amp;#039;روابط (.-) و (.*)&amp;#039;)&lt;br /&gt;
			elseif (match_num == 1) then&lt;br /&gt;
				local part1, part2, part3 = mw.ustring.match(input, &amp;#039;روابط (.-) و (.-) و (.*)&amp;#039;)&lt;br /&gt;
				if part1 and part2 then&lt;br /&gt;
					country1 = part1..&amp;#039; و &amp;#039;..part2&lt;br /&gt;
				else&lt;br /&gt;
					country1 = &amp;#039;&amp;#039;&lt;br /&gt;
				end&lt;br /&gt;
				country2 = part3&lt;br /&gt;
			elseif (match_num == 2) then&lt;br /&gt;
				local part1, part2, part3 = mw.ustring.match(input, &amp;#039;روابط (.-) و (.-) و (.*)&amp;#039;)&lt;br /&gt;
				country1 = part1&lt;br /&gt;
				if part2 and part3 then&lt;br /&gt;
					country2 = part2..&amp;#039; و &amp;#039;..part3&lt;br /&gt;
				else&lt;br /&gt;
					country2 = &amp;#039;&amp;#039;&lt;br /&gt;
				end&lt;br /&gt;
			elseif (match_num == 3) then&lt;br /&gt;
				local part1, part2, part3, part4 = mw.ustring.match(input, &amp;#039;روابط (.-) و (.-) و (.-) و (.*)&amp;#039;)&lt;br /&gt;
				if part1 and part2 then&lt;br /&gt;
					country1 = part1..&amp;#039; و &amp;#039;..part2&lt;br /&gt;
				else&lt;br /&gt;
					country1 = &amp;#039;&amp;#039;&lt;br /&gt;
				end&lt;br /&gt;
				if part3 and part4 then&lt;br /&gt;
					country2 = part3..&amp;#039; و &amp;#039;..part4&lt;br /&gt;
				else&lt;br /&gt;
					country2 = &amp;#039;&amp;#039;&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			&lt;br /&gt;
			match_num = match_num + 1&lt;br /&gt;
			&lt;br /&gt;
			for _, v in pairs(countries) do&lt;br /&gt;
				if v == country1 then&lt;br /&gt;
					table.insert(names, v)								-- If a match is found in input from &amp;quot;countries&amp;quot; table, store it and ...&lt;br /&gt;
					c1_found = true&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			for _, v in pairs(countries) do&lt;br /&gt;
				if v == country2 then&lt;br /&gt;
					table.insert(names, v)&lt;br /&gt;
					c2_found = true&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		until ((c1_found and c2_found) or (match_num &amp;gt; 3))&lt;br /&gt;
	else&lt;br /&gt;
		while (j &amp;lt;= #countries) do&lt;br /&gt;
			if mw.ustring.match(input, replace_spaces(countries[j]), 1) then&lt;br /&gt;
				table.insert(names, countries[j])									-- If a match is found in input from &amp;quot;countries&amp;quot; table, store it and ...&lt;br /&gt;
			end&lt;br /&gt;
			j = j + 1																-- ... continue the loop to find more country names&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	-- Value of &amp;quot;output&amp;quot; depends on args[&amp;#039;all&amp;#039;]&lt;br /&gt;
	--	if args[&amp;#039;all&amp;#039;] == true&lt;br /&gt;
	--		&amp;quot;output&amp;quot; will be a string of all countries found in &amp;quot;input&amp;quot;&lt;br /&gt;
	--		separated by comma (or user-defined separator)&lt;br /&gt;
	--  else&lt;br /&gt;
	--		output will be the first (or args[1]th)&lt;br /&gt;
	--  	country name in &amp;quot;names&amp;quot; table&lt;br /&gt;
	local output&lt;br /&gt;
	if yesno(args[&amp;#039;همه&amp;#039;]) then&lt;br /&gt;
		output = #names &amp;gt; 1 and table.concat(names, args[3] or &amp;#039;، &amp;#039;) or names[1]&lt;br /&gt;
	else&lt;br /&gt;
		output = names[tonumber(arg)]&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if #names == 0 then&lt;br /&gt;
		table.insert(tracking, &amp;#039;[[رده:الگوی نام کشور از رشته بدون استخراج نام کشور|{{نام‌صفحه}}]]&amp;#039;)&lt;br /&gt;
		if output then&lt;br /&gt;
			output = output .. table.concat(tracking, &amp;#039;&amp;#039;)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return output&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Shahroudi</name></author>
	</entry>
</feed>