Модуль:Ustring test

Материал из Справочника наблюдателя
Перейти к:навигация, поиск

(i)      Описание модуля[]

Result:

true 38В mw.ustring
true 38В ustring — ERROR
true 38В mw.ustring, the second capture added
true 38В ustring, the second capture added

local p = {}
local ustring = require( 'ustring' )

function p.Main( frame )

	local str = 'ст.38В с учета'
	local pattern1 = '^ст%.(%d%d[АБВГД]) с учета$'
	local pattern2 = '^ст%.(%d%d[АБВГД]) (с) учета$'
	
	t1m, r1m = pcall( mw.ustring.match, str, pattern1 ) 
	t1u, r1u = pcall(    ustring.match, str, pattern1 ) 
	
	t2m, r2m = pcall( mw.ustring.match, str, pattern2 ) 
	t2u, r2u = pcall(    ustring.match, str, pattern2 )  
	
	return 
		'{| class="wikitable"' ..
		'\n|-\n|' ..  tostring(t1m) .. '||' .. r1m .. '|| mw.ustring' ..
		'\n|-\n|' ..  tostring(t1u) .. '||' .. r1u .. '|| ustring — ERROR' ..
		'\n|-\n|' ..  tostring(t2m) .. '||' .. r2m .. '|| mw.ustring, the second capture added' ..
		'\n|-\n|' ..  tostring(t2u) .. '||' .. r2u .. '|| ustring, the second capture added' ..
		'\n|}'
	
--	return (tostring(a) or '(-)') .. ' ' .. (b or '(-)') .. ' ' .. (tostring(c) or '(-)') .. ' ' .. (d or '(-)')
end
	
return p