Jump to content
Main menu
Main menu
move to sidebar
hide
Ka papa huli mea
Papa Kinohi
Ka hui kaiaulu
Nā loli hou
He mo‘olelo kaulele
Kōkua
Nā papa nui
Huli
Huli
Appearance
E lūlū mai
Kāinoa
ʻEʻe
Hāmeʻa ponoʻī
E lūlū mai
Kāinoa
ʻEʻe
Ke ho‘ololi nei iā
Module
:
String2
Add languages
Module
Kūkākūkā
English
Heluhelu
Edit source
Nānā i ka mōʻaukala
Hāmeʻa
Tools
move to sidebar
hide
Actions
Heluhelu
Edit source
Nānā i ka mōʻaukala
General
He aha e loulou iho ai
Nā loli hou ʻālike
Ho'ohui i ka waihona
ʻIke ʻaoʻao
Get shortened URL
Switch to legacy parser
In other projects
Wikidata item
Appearance
move to sidebar
hide
Warning:
You are not logged in. Once you make an edit, a temporary account will be created for you.
Learn more
.
Log in
or
create an account
to continue receiving notifications after this account expires, and to access other features.
Anti-spam check. Do
not
fill this in!
--[[ Кое-какие дополнительные функции для строк ]] local M = { bs=function(f)-- первый параметр до начала второго параметра (или до конца, если он не встретился) --необяз. 3-й параметр - с какого по номеру (с 1) символа начинать поиск. return mw.ustring.sub(f.args[1], 1, (mw.ustring.find(f.args[1],f.args[2],tonumber(f.args[3] or 1),true) or 0)-1) end; as=function(f)-- первый параметр после начала второго параметра return mw.ustring.sub(f.args[1], (mw.ustring.find(f.args[1],f.args[2],1,true) or 0)+1) end; Tr=function(s,f,t,cf,df,sf)-- транслитерация первого параметра путём замены символов из второго параметра символами из третьего. -- Отдельными параметрами можно передавать флаги c, d и s, как в Perl; диапазоны в замене не работают, только в левой части -- (т.е. дефис надо передавать первым или последним). Второй результат - число заменённых символов local r, l, l2 = {}, mw.ustring.len(f), mw.ustring.len(t); for i = 1, l do r[mw.ustring.sub(f,i,i)] = i<=l2 and mw.ustring.sub(t,i,i) or df and '' or mw.ustring.sub(t,l2,l2) end local n2=0; local res, n = mw.ustring.gsub( s, ('[%s%s]%s'):format( cf and '^' or '', f:gsub('%','%%'):gsub(']','%]'):gsub('^%^','%^'), sf and '+' or '' ), sf and function(cc) n2 = n2+mw.ustring.len(cc)-1; return mw.ustring.gsub(cc,'.',r) end or r ) return res, n+n2 end; -- tr = function(f) return (M.Tr(f.args[1],f.args[2],f.args[3],f.args['c'],f.args['d'],f.args['s'])) end;-- транслитерировать -- trс = function(f) return ({M.Tr(f.args[1],f.args[2],f.args[3],f.args['c'],f.args['d'],f.args['s'])})[2] end;-- посчитать символы Trg = function(s,t,f,fi)-- Производит замену строк произвольной длины (если с fi, регистр не учитывает). -- Приоритет - по порядку в таблицах. for n,p in ipairs(t) do t[n] = {fi and mw.ustring.upper(p) or p,mw.ustring.len(p)} end local r,i,l,N = {},1,mw.ustring.len(s),0 while i<=l do (function() for n,p in ipairs(t) do if ( fi and mw.ustring.upper(mw.ustring.sub(s,i,i+p[2]-1)) or mw.ustring.sub(s,i,i+p[2]-1) ) == p[1] then table.insert(r,f[n]); i = i+p[2]; N=N+1; return end end table.insert(r,mw.ustring.sub(s,i,i)); i=i+1; return end)() end return table.concat(r),N end; trg = function(frame)--Работает с номерными аргументами шаблона,если задан параметр u, иначе со своими. -- Заменяет в первом аргументе аргументы 2, 4, 6... на аргументы 3, 5, 7... local tf, t, f, i= frame.args['u'] and frame.getParent() or f, {}, {}, 1; while tf.args[2*i] do t[tf.args[2*i]]=tf.args[2*i+1] or '' end return ( M.Trg(tf.args[1],t,f,(frame.args['i'] or '')~='') ) end; join = function (f) --объединяет нумерованные аргументы вызвавшего шаблона -- от from или 1 до to или первого отсутствующего -- через первый параметр invoke. Последний элемент можно присоединять иначе, задав второй параметр. -- По умолчанию ',' & 'и' -- Если 3-й параметр invoke — "s", строки из пробелов игнорируются; если "_", игнорируются пустые строки local t, tf, i = {}, f:getParent(), tonumber(f.args.from) or 1 local k,j,m = tonumber(f.args.to),i,f.args[3] while k and i<=k or tf.args[i] do if ( ({ ['_']=function(s)return s~=''end; ['s']=function(s)return not tostring(s):match("^%s*$")end })[m] or function() return true end )(tf.args[i]) then t[j]=tf.args[i]; j=j+1 end; i=i+1 end return mw.text.listToText(t,f.args[1],f.args[2] or f.args[1]) end } function M.formatRound(frame) --форматирует число, чтобы оно имело order знаков после запятой return string.format("%0."..frame.args[2].."f",tonumber(frame.args[1])); end return M
Hō'ulu'ulu mana'o
By saving changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
This site is protected by hCaptcha and its
Privacy Policy
and
Terms of Service
apply.
JavaScript is required to continue. Turn on JavaScript in your browser settings and refresh the page.
Publish changes
E hō'ike hou
Ho‘ōki
Kōkua ho‘ololi
(wehe ʻia i loko o kekahi pukaaniani hou)
Preview page with this template
Wikidata entities used in this page
Module:String2
: Sitelink, Description: en
anakuhi e hana ʻia ma kēia ʻaoʻao:
Module:String2/doc
(
hoʻololi
)
Huli
Huli
Ke ho‘ololi nei iā
Module
:
String2
Add languages
Hoʻohui kumuhana