Movatterモバイル変換


[0]ホーム

URL:


Jump to content
Wikipedia
Paghanap

Module:MultiReplace

Gikan sa Bikol Sentral na Wikipedia, an talingkas na ensiklopedya
Module documentation[create] [purge]
You might want tocreate a documentation page for thisScribunto module.
Editors can experiment in this module's sandbox(create |mirror) and testcases(create) pages.
Add categories to the/doc subpage.Subpages of this module.
p={}localfunctionMultiReplace(args)localinput=args[1]or"{{{1}}}"localplain=args.plain=="yes"locali=1localchangeList={}whileargs[i*2]dolocalchange={pattern=args[i*2],repl=args[i*2+1]}ifnotchange.replthenreturnrequire('Module:Error').error{'MultiReplace: Unpaired argument: <code>'..(i*2)..' = '..change.pattern..'</code>'}endchangeList[i]=changei=i+1endlocalmatchList={}localpos=1locallen=mw.ustring.len(input)localresult=""whilepos<=lendolocalbestStart=len+1localbestStop=lenlocalbestChangefor_,changeinipairs(changeList)dolocalstart,stop=mw.ustring.find(input,change.pattern,pos,plain)ifstartand(start<bestStart)thenbestStart=startbestStop=stopbestChange=changeendendresult=result..mw.ustring.sub(input,pos,bestStart-1)ifbestChangethenlocalfragment=mw.ustring.sub(input,bestStart,bestStop)result=result..(plainandbestChange.replormw.ustring.gsub(fragment,bestChange.pattern,bestChange.repl,1))endpos=bestStop+1endreturnresultendfunctionp.main(frame,...)localargs=type(frame)~='table'and{frame,...}ortype(frame.args)~='table'andframeorframe.args[1]andframe.argsorframe:getParent().argsreturnMultiReplace(args)endreturnp
Kinua sa "https://bcl.wikipedia.org/w/index.php?title=Module:MultiReplace&oldid=183595"

[8]ページ先頭

©2009-2025 Movatter.jp