Module:Sandbox/Mr. Ibrahem

local p = {}

function p.count_ref(frame) --   local title = frame.args[1] local _; local page_title_object = mw.title.new(title); local text = page_title_object:getContent; local count; _, count = mw.ustring.gsub (text or '', '/]*>', '%1'); --mw.log(_) return count; end

function p.EntityIdForTitle(frame) -- 	local title = frame.args[1] local str = mw.wikibase.getEntityIdForTitle( title ) return str end

function p.count_temp(frame) -- 	local title = frame.args[1] local _; local page_title_object = mw.title.new(title); local text = page_title_object:getContent; local count; _, count = mw.ustring.gsub (text or '', '({{%s*[Hh]arv[nbcolptx]*%s*|)', '%1'); local count2; __, count2 = mw.ustring.gsub (text or '', '({{%s*[Ss]fn[mp]?%s*|)', '%1'); local allcount = count + count2 return allcount; end

function p.tab(frame) local title = frame.args[1] local _,ref; local page_title_object = mw.title.new(title); local text = page_title_object:getContent; text = mw.ustring.gsub(text, "%{%|", " ") --text = string.gsub(text, "%{%|", " ") mw.log(text) -- \{\|.*?\|\}	local pattern = '' local tstart, tend = text:find (pattern, 1 , false ); --mw.ustring.find( source_str, pattern, start_pos, plain ) local total = 0; while tstart do --mw.log(mw.ustring.sub(text, tstart, tend)) ref = text:sub(tstart, tend) --mw.log( ref  ) total = total + #ref; tstart = tend; tstart, tend = text:find (pattern, tstart, false ); end return total; end

function p.ref_len(frame) -- {{#invoke:Sandbox/Mr. Ibrahem|ref_len|Yemen}} local title = frame.args[1] local _,ref; local page_title_object = mw.title.new(title); local text = page_title_object:getContent or ''; local pattern = '(]*>[^<>]+ )' local tstart, tend = text:find (pattern, 1 , false ); --mw.ustring.find( source_str, pattern, start_pos, plain ) local total = 0; while tstart do --mw.log(mw.ustring.sub(text, tstart, tend)) ref = text:sub(tstart, tend) mw.log( ref  ) total = total + #ref; tstart = tend; tstart, tend = text:find (pattern, tstart, false ); end return total; end

return p