모듈:String/설명문서 편집하기

편집하면 당신의 IP 주소가 공개적으로 기록됩니다. 계정을 만들고 로그인하면 편집 시 사용자 이름만 보이며, 위키 이용에 여러 가지 편의가 주어집니다.

편집을 취소할 수 있습니다. 이 편집을 되돌리려면 아래의 바뀐 내용을 확인한 후 게시해주세요.

최신판 당신의 편집
19번째 줄: 19번째 줄:


[[모듈:String/연습장]]에서 모듈을 테스트 해볼 수 있습니다.
[[모듈:String/연습장]]에서 모듈을 테스트 해볼 수 있습니다.
=== len ===
대상 문자열의 길이를 출력합니다.
사용법:
<pre>{{#invoke:String|len|target_string}}</pre>
또는
<pre>{{#invoke:String|len|s=target_string}}</pre>
<pre>{{#invoke:String|len|asdfghjkl}}</pre>
{{#invoke:String|len|asdfghjkl}}
이름 있는 변수 s 를 사용하여 함수를 불러올 경우
대상 문자열에서 선행 또는 후행 공백이 자동 삭제됩니다.
=== sub ===
이 함수는 원본 문자열에서 지정된 범위의 문자열을 반환합니다.
사용법:
<pre>{{#invoke:String|sub|원본 문자열|시작점|끝점}}</pre>
<pre>{{#invoke:String|sub|s=원본 문자열|i=시작점|j=끝점}}</pre>
<pre>{{#invoke:String|sub|asdfghjkl|4|6}}</pre>
{{#invoke:String|sub|asdfghjkl|4|6}}
변수
    s: 원본 문자열
    i: 반환할 문자열의 시작점, 기본값은 1
    j: 반환할 문자열의 끝점, 기본값은 문자열 끝까지
문자열의 첫 번째 문자의 인덱스는 1입니다. i나 j가 음수이면 문자열의 맨 뒤에서부터 위치가 계산됩니다. 예를 들어 abcd의 인덱스 1은 a, 인덱스 -1은 d입니다.
인덱스가 문자열의 범위를 벗어나면 오류를 반환합니다.
=== _match ===
사용법 : require("Module:String")._match
strmatch = require("Module:String")._match
sresult = strmatch( s, pattern, start, match, plain, nomatch )
다른 모듈에 포함해서 사용하는 함수입니다.
변수
    s: 대상 문자열
    pattern: 대상 문자열에서 찾을 문자열이나 정규식(패턴)을 입력합니다.
    start: The index within the source string to start the search.  The first
        character of the string has index 1.  Defaults to 1.
    match: In some cases it may be possible to make multiple matches on a single
        string.  This specifies which match to return, where the first match is
        match= 1.  If a negative number is specified then a match is returned
        counting from the last match.  Hence match = -1 is the same as requesting
        the last match.  Defaults to 1.
    plain: A flag indicating that the pattern should be understood as plain
        text.  Defaults to false.
    nomatch: If no match is found, output the "nomatch" value rather than an error.
For information on constructing Lua patterns, a form of [regular expression], see:
* http://www.lua.org/manual/5.1/manual.html#5.4.1
* http://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Patterns
* http://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Ustring_patterns
=== match ===
원본 문자열에서 정규식(패턴)과 일치하는 문자열을 찾아 반환합니다.
사용법:
<pre>{{#invoke:String|match|원본 문자열|패턴(정규식)|start_index|match_number|plain_flag|nomatch_output}}</pre>
or
<pre>{{#invoke:String|match|s=원본 문자열|pattern=패턴(정규식)|start=start_index
    |match=match_number|plain=plain_flag|nomatch=nomatch_output}}</pre>
변수
    s: 원본 문자열
    pattern: 원본 문자열에서 찾을 문자열/패턴
    start: 검색을 시작할 위치. 첫 번째 문자의 인덱스는 1입니다. 기본값은 1.
    match: In some cases it may be possible to make multiple matches on a single
        string.  This specifies which match to return, where the first match is
        match= 1.  If a negative number is specified then a match is returned
        counting from the last match.  Hence match = -1 is the same as requesting
        the last match.  Defaults to 1.
    plain: A flag indicating that the pattern should be understood as plain
        text.  Defaults to false.
    nomatch: If no match is found, output the "nomatch" value rather than an error.
If invoked using named 변수, Mediawiki will automatically remove any leading or
trailing whitespace from each string.  In some circumstances this is desirable, in
other cases one may want to preserve the whitespace.
If the match_number or start_index are out of range for the string being queried, then
this function generates an error.  An error is also generated if no match is found.
If one adds the parameter ignore_errors=true, then the error will be suppressed and
an empty string will be returned on any failure.
For information on constructing Lua patterns, a form of [regular expression], see:
* http://www.lua.org/manual/5.1/manual.html#5.4.1
* http://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Patterns
* http://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Ustring_patterns
=== pos ===
This function returns a single character from the target string at position pos.
사용법:
<pre>{{#invoke:String|pos|target_string|index_value}}</pre>
or
<pre>{{#invoke:String|pos|target=target_string|pos=index_value}}</pre>
<pre>{{#invoke:String|pos|asdfghjkl|3}}</pre>
{{#invoke:String|pos|asdfghjkl|3}}
변수
    target: The string to search
    pos: The index for the character to return
If invoked using named 변수, Mediawiki will automatically remove any leading or
trailing whitespace from the target string.  In some circumstances this is desirable, in
other cases one may want to preserve the whitespace.
The first character has an index value of 1.
If one requests a negative value, this function will select a character by counting backwards
from the end of the string.  In other words pos = -1 is the same as asking for the last character.
A requested value of zero, or a value greater than the length of the string returns an error.
=== find ===
This function allows one to search for a target string or pattern within another
string.
사용법:
<pre>{{#invoke:String|find|source_str|target_string|start_index|plain_flag}}</pre>
or
<pre>{{#invoke:String|find|source=source_str|target=target_str|start=start_index|plain=plain_flag}}</pre>
<pre>{{#invoke:String|find|asdfghjkl|asdf}}</pre>
{{#invoke:String|find|asdfghjkl|asdf}}
변수
    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
If invoked using named 변수, Mediawiki will automatically remove any leading or
trailing whitespace from the parameter.  In some circumstances this is desirable, in
other cases one may want to preserve the whitespace.
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.
This function should be safe for UTF-8 strings.
=== gsub ===
This function allows one to replace a target string or pattern within another
string.
사용법:
<pre>{{#invoke:String|gsub|source_str|pattern_string|replace_string|replacement_count|plain_flag}}</pre>
or
<pre>{{#invoke:String|gsub|source=source_string|pattern=pattern_string|replace=replace_string|count=replacement_count|plain=plain_flag}}</pre>
<pre>{{#invoke:String|gsub|asdfghjkl|asdf|qwer}}</pre>
{{#invoke:String|gsub|asdfghjkl|asdf|qwer}}
변수
    source: The string to search
    pattern: The string or pattern to find within source
    replace: The replacement text
    count: The number of occurences to replace, defaults to all.
    plain: Boolean flag indicating that pattern should be understood as plain
        text and not as a Lua style regular expression, defaults to true
=== rep ===
Repeat
=== escapePattern ===
This function escapes special characters from a Lua string pattern. See [1]
for details on how patterns work.
[1] https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Patterns
사용법:
<pre>{{#invoke:String|escapePattern|pattern_string}}</pre>
변수
    pattern_string: The pattern string to escape.
=== count ===
=== join ===
Join all non empty arguments together; the first argument is the separator.
사용법:
<pre>{{#invoke:String|join|sep|one|two|three}}</pre>
{{#invoke:String|join|{{!}}|one|two|three}}


{{퍼온문서|문서=모듈:string|판=27795255|일부=}}
{{퍼온문서|문서=모듈:string|판=27795255|일부=}}
리브레 위키에서의 모든 기여는 크리에이티브 커먼즈 저작자표시-동일조건변경허락 3.0 라이선스로 배포됩니다(자세한 내용에 대해서는 리브레 위키:저작권 문서를 읽어주세요). 만약 여기에 동의하지 않는다면 문서를 저장하지 말아 주세요.
글이 직접 작성되었거나 호환되는 라이선스인지 확인해주세요. 리그베다 위키, 나무위키, 오리위키, 구스위키, 디시위키 및 CCL 미적용 사이트 등에서 글을 가져오실 때는 본인이 문서의 유일한 기여자여야 하고, 만약 본인이 문서의 유일한 기여자라는 증거가 없다면 그 문서는 불시에 삭제될 수 있습니다.
취소 편집 도움말 (새 창에서 열림)

| () [] [[]] {{}} {{{}}} · <!-- --> · [[분류:]] · [[파일:]] · [[미디어:]] · #넘겨주기 [[]] · {{ㅊ|}} · <onlyinclude></onlyinclude> · <includeonly></includeonly> · <noinclude></noinclude> · <br /> · <ref></ref> · {{각주}} · {|class="wikitable" · |- · rowspan=""| · colspan=""| · |}

이 문서에서 사용한 틀:

이 문서는 다음의 숨은 분류 1개에 속해 있습니다: