Module:String/doc/de: Difference between revisions
ThisCarthing (talk | contribs) Created page with "ODER" |
Updating to match new version of source page |
||
| (29 intermediate revisions by 2 users not shown) | |||
| Line 6: | Line 6: | ||
<includeonly>{{Languages|Module:String/doc}}</includeonly> |
<includeonly>{{Languages|Module:String/doc}}</includeonly> |
||
<!-- Add categories where indicated at the bottom of this page and interwikis at Wikidata --> |
<!-- Add categories where indicated at the bottom of this page and interwikis at Wikidata --> |
||
{{Magic words|general=1}} |
|||
{{Shared Template Warning|Module:String}} |
|||
{{Module rating|release}} |
{{Module rating|release}} |
||
{{Module rating|protected}} |
{{Module rating|protected}} |
||
| Line 17: | Line 17: | ||
<span lang="en" dir="ltr" class="mw-content-ltr">Depending on the intended use, it may be advantageous to either preserve or remove such whitespace.</span> |
<span lang="en" dir="ltr" class="mw-content-ltr">Depending on the intended use, it may be advantageous to either preserve or remove such whitespace.</span> |
||
<span id="Global_options"></span> |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
== |
== Globale Optionen == |
||
</div> |
|||
; <code>ignore_errors</code> |
; <code>ignore_errors</code> |
||
: <span lang="en" dir="ltr" class="mw-content-ltr">If set to {{phpi|true}} or 1, any error condition will result in an empty string being returned rather than an error message.</span> |
: <span lang="en" dir="ltr" class="mw-content-ltr">If set to {{phpi|true}} or 1, any error condition will result in an empty string being returned rather than an error message.</span> |
||
; <code>error_category</code> |
; <code>error_category</code> |
||
: <span lang="en" dir="ltr" class="mw-content-ltr">If an error occurs, specifies the name of a category to include with the error message.</span> |
: <span lang="en" dir="ltr" class="mw-content-ltr">If an error occurs, specifies the name of a category to include with the error message.</span> Die Standardkategorie ist {{ll|Category:Errors reported by Module String}}. |
||
; <code>no_category</code> |
; <code>no_category</code> |
||
: <span lang="en" dir="ltr" class="mw-content-ltr">If set to {{phpi|true}} or 1, no category will be added if an error is generated.</span> |
: <span lang="en" dir="ltr" class="mw-content-ltr">If set to {{phpi|true}} or 1, no category will be added if an error is generated.</span> |
||
| Line 38: | Line 37: | ||
</div> |
</div> |
||
Verwendung: |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
Usage: |
|||
</div> |
|||
: {{tmpl|0=<code><nowiki>{{#invoke:</nowiki>String{{!}}len{{!}}''$1''<nowiki>}}</nowiki></code> |
: {{tmpl|0=<code><nowiki>{{#invoke:</nowiki>String{{!}}len{{!}}''$1''<nowiki>}}</nowiki></code> |
||
|1=ziel_zeichenkette |
|||
|1=<span lang="en" dir="ltr" class="mw-content-ltr">target_string</span> |
|||
}} |
}} |
||
| Line 49: | Line 46: | ||
: {{tmpl|0=<code><nowiki>{{#invoke:</nowiki>String{{!}}len{{!}}s= ''$1'' <nowiki>}}</nowiki></code> |
: {{tmpl|0=<code><nowiki>{{#invoke:</nowiki>String{{!}}len{{!}}s= ''$1'' <nowiki>}}</nowiki></code> |
||
|1=ziel_zeichenkette |
|||
|1=<span lang="en" dir="ltr" class="mw-content-ltr">target_string</span> |
|||
}} |
}} |
||
Parameter: |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
Parameters: |
|||
</div> |
|||
; <code>s</code> |
; <code>s</code> |
||
| Line 63: | Line 58: | ||
: <span lang="en" dir="ltr" class="mw-content-ltr">This function returns a substring of the target string at specified indices.</span> |
: <span lang="en" dir="ltr" class="mw-content-ltr">This function returns a substring of the target string at specified indices.</span> |
||
Verwendung: |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
Usage: |
|||
</div> |
|||
: {{tmpl|0=<code><nowiki>{{#invoke:</nowiki>String{{!}}sub{{!}}''$1''{{!}}''$2''{{!}}''$3''<nowiki>}}</nowiki></code> |
: {{tmpl|0=<code><nowiki>{{#invoke:</nowiki>String{{!}}sub{{!}}''$1''{{!}}''$2''{{!}}''$3''<nowiki>}}</nowiki></code> |
||
|1=ziel_zeichenkette |
|||
|1=<span lang="en" dir="ltr" class="mw-content-ltr">target_string</span> |
|||
|2=start_index |
|||
|2=<span lang="en" dir="ltr" class="mw-content-ltr">start_index</span> |
|||
|3=end_index |
|||
|3=<span lang="en" dir="ltr" class="mw-content-ltr">end_index</span> |
|||
}} |
}} |
||
| Line 76: | Line 69: | ||
: {{tmpl|0=<code><nowiki>{{#invoke:</nowiki>String{{!}}sub<wbr/>{{!}}s= ''$1'' {{!}}i= ''$2'' {{!}}j= ''$3'' <nowiki>}}</nowiki></code> |
: {{tmpl|0=<code><nowiki>{{#invoke:</nowiki>String{{!}}sub<wbr/>{{!}}s= ''$1'' {{!}}i= ''$2'' {{!}}j= ''$3'' <nowiki>}}</nowiki></code> |
||
|1=ziel_zeichenkette |
|||
|1=<span lang="en" dir="ltr" class="mw-content-ltr">target_string</span> |
|||
|2=start_index |
|||
|2=<span lang="en" dir="ltr" class="mw-content-ltr">start_index</span> |
|||
|3=end_index |
|||
|3=<span lang="en" dir="ltr" class="mw-content-ltr">end_index</span> |
|||
}} |
}} |
||
Parameter: |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
Parameters: |
|||
</div> |
|||
; <code>s</code> |
; <code>s</code> |
||
| Line 106: | Line 97: | ||
</div> |
</div> |
||
Verwendung: |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
Usage: |
|||
</div> |
|||
: {{tmpl|0=<code><nowiki>{{#invoke:</nowiki>String{{!}}match{{!}}''$1''{{!}}''$2''{{!}}''$3''{{!}}''$4''{{!}}''$5''{{!}}''$6''<nowiki>}}</nowiki></code> |
: {{tmpl|0=<code><nowiki>{{#invoke:</nowiki>String{{!}}match{{!}}''$1''{{!}}''$2''{{!}}''$3''{{!}}''$4''{{!}}''$5''{{!}}''$6''<nowiki>}}</nowiki></code> |
||
|1=<span lang="en" dir="ltr" class="mw-content-ltr">source_string</span> |
|1=<span lang="en" dir="ltr" class="mw-content-ltr">source_string</span> |
||
|2=<span lang="en" dir="ltr" class="mw-content-ltr">pattern_string</span> |
|2=<span lang="en" dir="ltr" class="mw-content-ltr">pattern_string</span> |
||
|3=start_index |
|||
|3=<span lang="en" dir="ltr" class="mw-content-ltr">start_index</span> |
|||
|4=<span lang="en" dir="ltr" class="mw-content-ltr">match_number</span> |
|4=<span lang="en" dir="ltr" class="mw-content-ltr">match_number</span> |
||
|5=<span lang="en" dir="ltr" class="mw-content-ltr">plain_flag</span> |
|5=<span lang="en" dir="ltr" class="mw-content-ltr">plain_flag</span> |
||
| Line 124: | Line 113: | ||
|1=<span lang="en" dir="ltr" class="mw-content-ltr">source_string</span> |
|1=<span lang="en" dir="ltr" class="mw-content-ltr">source_string</span> |
||
|2=<span lang="en" dir="ltr" class="mw-content-ltr">pattern_string</span> |
|2=<span lang="en" dir="ltr" class="mw-content-ltr">pattern_string</span> |
||
|3=start_index |
|||
|3=<span lang="en" dir="ltr" class="mw-content-ltr">start_index</span> |
|||
|4=<span lang="en" dir="ltr" class="mw-content-ltr">match_number</span> |
|4=<span lang="en" dir="ltr" class="mw-content-ltr">match_number</span> |
||
|5=<span lang="en" dir="ltr" class="mw-content-ltr">plain_flag</span> |
|5=<span lang="en" dir="ltr" class="mw-content-ltr">plain_flag</span> |
||
| Line 130: | Line 119: | ||
}} |
}} |
||
Parameter: |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
Parameters: |
|||
</div> |
|||
; <code>s</code> |
; <code>s</code> |
||
| Line 165: | Line 152: | ||
</div> |
</div> |
||
Verwendung: |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
Usage: |
|||
</div> |
|||
: {{tmpl|0=<code><nowiki>{{#invoke:</nowiki>String{{!}}pos{{!}}''$1''{{!}}''$2''<nowiki>}}</nowiki></code> |
: {{tmpl|0=<code><nowiki>{{#invoke:</nowiki>String{{!}}pos{{!}}''$1''{{!}}''$2''<nowiki>}}</nowiki></code> |
||
|1=ziel_zeichenkette |
|||
|1=<span lang="en" dir="ltr" class="mw-content-ltr">target_string</span> |
|||
|2=index_wert |
|||
|2=<span lang="en" dir="ltr" class="mw-content-ltr">index_value</span> |
|||
}} |
}} |
||
| Line 177: | Line 162: | ||
: {{tmpl|0=<code><nowiki>{{#invoke:</nowiki>String{{!}}pos{{!}}target= ''$1'' {{!}}pos= ''$2'' <nowiki>}}</nowiki></code> |
: {{tmpl|0=<code><nowiki>{{#invoke:</nowiki>String{{!}}pos{{!}}target= ''$1'' {{!}}pos= ''$2'' <nowiki>}}</nowiki></code> |
||
|1=ziel_zeichenkette |
|||
|1=<span lang="en" dir="ltr" class="mw-content-ltr">target_string</span> |
|||
|2=index_wert |
|||
|2=<span lang="en" dir="ltr" class="mw-content-ltr">index_value</span> |
|||
}} |
}} |
||
Parameter: |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
Parameters: |
|||
</div> |
|||
; <code>target</code> |
; <code>target</code> |
||
| Line 207: | Line 190: | ||
</div> |
</div> |
||
Verwendung: |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
Usage: |
|||
</div> |
|||
: {{tmpl|0=<code><nowiki>{{#invoke:</nowiki>String{{!}}find{{!}}''$1''{{!}}''$2''{{!}}''$3''{{!}}''$4''<nowiki>}}</nowiki></code> |
: {{tmpl|0=<code><nowiki>{{#invoke:</nowiki>String{{!}}find{{!}}''$1''{{!}}''$2''{{!}}''$3''{{!}}''$4''<nowiki>}}</nowiki></code> |
||
|1=<span lang="en" dir="ltr" class="mw-content-ltr">source_str</span> |
|1=<span lang="en" dir="ltr" class="mw-content-ltr">source_str</span> |
||
|2=ziel_zeichenkette |
|||
|2=<span lang="en" dir="ltr" class="mw-content-ltr">target_string</span> |
|||
|3=start_index |
|||
|3=<span lang="en" dir="ltr" class="mw-content-ltr">start_index</span> |
|||
|4=<span lang="en" dir="ltr" class="mw-content-ltr">plain_flag</span> |
|4=<span lang="en" dir="ltr" class="mw-content-ltr">plain_flag</span> |
||
}} |
}} |
||
| Line 222: | Line 203: | ||
: {{tmpl|0=<code><nowiki>{{#invoke:</nowiki>String{{!}}find{{!}}source= ''$1'' {{!}}target= ''$2'' {{!}}start= ''$3'' {{!}}plain= ''$4'' <nowiki>}}</nowiki></code> |
: {{tmpl|0=<code><nowiki>{{#invoke:</nowiki>String{{!}}find{{!}}source= ''$1'' {{!}}target= ''$2'' {{!}}start= ''$3'' {{!}}plain= ''$4'' <nowiki>}}</nowiki></code> |
||
|1=<span lang="en" dir="ltr" class="mw-content-ltr">source_str</span> |
|1=<span lang="en" dir="ltr" class="mw-content-ltr">source_str</span> |
||
|2=ziel_zkt |
|||
|2=<span lang="en" dir="ltr" class="mw-content-ltr">target_str</span> |
|||
|3=start_index |
|||
|3=<span lang="en" dir="ltr" class="mw-content-ltr">start_index</span> |
|||
|4=<span lang="en" dir="ltr" class="mw-content-ltr">plain_flag</span> |
|4=<span lang="en" dir="ltr" class="mw-content-ltr">plain_flag</span> |
||
}} |
}} |
||
Parameter: |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
Parameters: |
|||
</div> |
|||
; <code>source</code> |
; <code>source</code> |
||
| Line 255: | Line 234: | ||
</div> |
</div> |
||
Verwendung: |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
Usage: |
|||
</div> |
|||
: {{tmpl|0=<code><nowiki>{{#invoke:</nowiki>String{{!}}replace{{!}}''$1''{{!}}''$2''{{!}}''$3''{{!}}''$4''{{!}}''$5''<nowiki>}}</nowiki></code> |
: {{tmpl|0=<code><nowiki>{{#invoke:</nowiki>String{{!}}replace{{!}}''$1''{{!}}''$2''{{!}}''$3''{{!}}''$4''{{!}}''$5''<nowiki>}}</nowiki></code> |
||
| Line 277: | Line 254: | ||
}} |
}} |
||
Parameter: |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
Parameters: |
|||
</div> |
|||
; <code>source</code> |
; <code>source</code> |
||
| Line 298: | Line 273: | ||
</div> |
</div> |
||
Verwendung: |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
Usage: |
|||
</div> |
|||
: {{tmpl|0=<code><nowiki>{{#invoke:</nowiki>String{{!}}rep{{!}}''$1''{{!}}''$2''<nowiki>}}</nowiki></code> |
: {{tmpl|0=<code><nowiki>{{#invoke:</nowiki>String{{!}}rep{{!}}''$1''{{!}}''$2''<nowiki>}}</nowiki></code> |
||
| Line 307: | Line 280: | ||
}} |
}} |
||
Parameter: |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
Parameters: |
|||
</div> |
|||
; <code>source</code> |
; <code>source</code> |
||
Latest revision as of 02:46, 19 October 2025
| Dies ist eine Dokumentations-Unterseite zu Module:String/doc It contains usage information, categories and other content that is not part of the original Module page. |
| This module is rated as ready for general use. It has reached a mature form and is thought to be bug-free and ready for use wherever appropriate. It is ready to mention on help pages and other resources as an option for new users to learn. To reduce server load and bad output, it should be improved by sandbox testing rather than repeated trial-and-error editing. |
| This module is subject to page protection. It is a highly visible module in use by a very large number of pages. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing. |
This module is intended to provide access to basic string functions.
Most of the functions provided here can be invoked with named parameters, unnamed parameters, or a mixture. If named parameters are used, MediaWiki will automatically remove any leading or trailing whitespace from the parameter. Depending on the intended use, it may be advantageous to either preserve or remove such whitespace.
Globale Optionen
ignore_errors- If set to
trueor 1, any error condition will result in an empty string being returned rather than an error message. error_category- If an error occurs, specifies the name of a category to include with the error message. Die Standardkategorie ist Category:Errors reported by Module String.
no_category- If set to
trueor 1, no category will be added if an error is generated.
Unit tests for this module are available at Module:String/testcases.
len
This function returns the length of the target string.
Verwendung:
{{#invoke:String|len|ziel_zeichenkette}}
ODER
{{#invoke:String|len|s= ziel_zeichenkette }}
Parameter:
s- The string whose length to report
sub
- This function returns a substring of the target string at specified indices.
Verwendung:
{{#invoke:String|sub|ziel_zeichenkette|start_index|end_index}}
ODER
{{#invoke:String|sub|s= ziel_zeichenkette |i= start_index |j= end_index }}
Parameter:
s- The string to return a subset of
i- The first index of the substring to return, defaults to 1.
j- The last index of the string to return, defaults to the last character.
The first character of the string is assigned an index of 1. If either i or j is a negative value, it is interpreted the same as selecting a character by counting from the end of the string. Hence, a value of -1 is the same as selecting the last character of the string.
If the requested indices are out of range for the given string, an error is reported.
match
This function returns a substring from the source string that matches a specified pattern.
Verwendung:
{{#invoke:String|match|source_string|pattern_string|start_index|match_number|plain_flag|nomatch_output}}
ODER
{{#invoke:String|match|s= source_string |pattern= pattern_string |start= start_index |match= match_number |plain= plain_flag |nomatch= nomatch_output }}
Parameter:
s- The string to search
pattern- The pattern or string to find within the string
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. Hencematch = -1is the same as requesting the last match. Defaults to 1. plain- Boolean flag indicating that pattern should be understood as plain text and not as a Lua-style regular expression. Defaults to
false. nomatch- If no match is found, output the "nomatch" value rather than an error.
If the match or start 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:
- Lua reference: Patterns - as of version 5.1
- Scribunto patterns
- Scribunto Unicode string patterns
pos
This function returns a single character from the target string at position pos.
Verwendung:
{{#invoke:String|pos|ziel_zeichenkette|index_wert}}
ODER
{{#invoke:String|pos|target= ziel_zeichenkette |pos= index_wert }}
Parameter:
target- The string to search
pos- The index for the character to return
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.
Verwendung:
{{#invoke:String|find|source_str|ziel_zeichenkette|start_index|plain_flag}}
ODER
{{#invoke:String|find|source= source_str |target= ziel_zkt |start= start_index |plain= plain_flag }}
Parameter:
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.
This function should be safe for UTF-8 strings.
replace
This function allows one to replace a target string or pattern within another string.
Verwendung:
{{#invoke:String|replace|source_str|pattern_string|replace_string|replacement_count|plain_flag}}
ODER
{{#invoke:String|replace|source= source_string |pattern= pattern_string |replace= replace_string |count= replacement_count |plain= plain_flag }}
Parameter:
source- The string to search
pattern- The string or pattern to find within source
replace- The replacement text
count- The number of occurrences to replace; defaults to all
plain- Boolean flag indicating that pattern should be understood as plain text and not as a Scribunto ustring pattern (a unicode-friendly Lua-style regular expression); defaults to
true
rep
Repeats a string n times.
Verwendung:
{{#invoke:String|rep|source|count}}
Parameter:
source- The string to repeat
count- The number of repetitions.
Example {{#invoke:String|rep|hello|3}} gives hellohellohello