경고: 이 문서의 오래된 판을 편집하고 있습니다. 이것을 게시하면, 이 판 이후로 바뀐 모든 편집이 사라집니다.귀하는 로그인되어 있지 않습니다. 이대로 편집하면 귀하의 IP 주소가 편집 기록에 남게 됩니다.스팸 방지 검사입니다. 이것을 입력하지 마세요!local str = {} function str.len( frame ) return mw.ustring.len( frame.args.s ) end function str.sub( frame ) return mw.ustring.sub( frame.args.s, tonumber( frame.args.i ), tonumber( frame.args.j ) ) end function str.sublength( frame ) local i = tonumber( frame.args.i ) or 0 local len = tonumber( frame.args.len ) return mw.ustring.sub( frame.args.s, i + 1, len and ( i + len ) ) end function str.match( frame ) return mw.ustring.match( frame.args.s, frame.args.pattern, tonumber( frame.args.i ) ) end --[====[ str_find This function duplicates the behavior of {{str_find}}, including all of its quirks. This is provided in order to support existing templates, but is NOT RECOMMENDED for new code and templates. New code is recommended to use the "find" function instead. Returns the first index in "source" that is a match to "target". Indexing is 1-based, and the function returns -1 if the "target" string is not present in "source". Both strings have any leading or trailing whitespace removed before searching. Important Note: If the "target" string is empty / missing, this function returns a value of "1", which is generally unexpected behavior, and must be accounted for separatetly. ]====] function str.str_find( frame ) local source_str = frame.args.source or ''; local target_str = frame.args.target or ''; if target_str == '' then return 1; end local start = mw.ustring.find( source_str, target_str, 1, true ) if start == nil then start = -1 end return start end --[====[ find This function allows one to search for a target string or pattern within another string. Parameters: source: The string to search target: The string or pattern to find within source start: The index within the source string to start the search, defaults to 1 plain: Boolean flag indicating that target should be understood as plain text and not as a Lua style regular expression, defaults to true This function returns the first index >= "start" where "target" can be found within "source". Indices are 1-based. If "target" is not found, then this function returns 0. If either "source" or "target" are missing / empty, this function also returns 0. Both "source" and "target" will be trimmed so that any leading or trailing whitespace is removed prior to searching. This function should be safe for UTF-8 strings. ]====] function str.find( frame ) local source_str = frame.args.source or ''; local pattern = frame.args.target or ''; local start_pos = tonumber(frame.args.start) or 1; local plain = frame.args.plain or true; if source_str == '' or pattern == '' then return 0; end if type( plain ) == 'string' then plain = plain:lower(); if plain == 'false' or plain == 'no' or plain == '0' then plain = false; else plain = true; end end local start = mw.ustring.find( source_str, pattern, start_pos, plain ) if start == nil then start = 0 end return start end return str 편집 요약 가온 위키에서의 모든 기여는 크리에이티브 커먼즈 저작자표시-동일조건변경허락 라이선스로 배포된다는 점을 유의해 주세요(자세한 내용에 대해서는 가온 위키:저작권 문서를 읽어주세요). 만약 여기에 동의하지 않는다면 문서를 저장하지 말아 주세요. 또한, 직접 작성했거나 퍼블릭 도메인과 같은 자유 문서에서 가져왔다는 것을 보증해야 합니다. 저작권이 있는 내용을 허가 없이 저장하지 마세요! 취소 편집 도움말 (새 창에서 열림) 이 문서에서 사용한 틀: 모듈:String/설명문서 (편집)