Vorlage:Strsub
Aus Kitakien
(Unterschied zwischen Versionen)
K (Schützte „Vorlage:Strsub“: Selten zu ändernde Vorlage ([edit=autoconfirmed] (unbeschränkt) [move=sysop] (unbeschränkt))) |
|||
(Der Versionsvergleich bezieht 13 dazwischenliegende Versionen mit ein.) | |||
Zeile 1: | Zeile 1: | ||
- | {{#ifeq:{{{2|0}}}|0|{{ | + | <includeonly>{{{{{subst|}}}#ifeq:{{{2|0}}}|0|{{{{{subst|}}}strleft|subst={{{subst|}}}|{{{1}}}|{{#expr{{{3|0}}}-1}}}}|<!-- |
- | -->{{#ifexpr:{{{2|0}}} <= 1 and {{{2|0}}} + {{{3|0}}} >= 1|<!-- | + | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 1 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 1|<!-- |
- | -->{{ | + | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|1}}}}<!-- |
- | -->{{#ifexpr:{{{2|0}}} <= 2 and {{{2|0}}} + {{{3|0}}} >= 2|<!-- | + | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 2 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 2|<!-- |
- | -->{{ | + | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|2}}}}<!-- |
- | -->{{#ifexpr:{{{2|0}}} <= 3 and {{{2|0}}} + {{{3|0}}} >= 3|<!-- | + | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 3 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 3|<!-- |
- | -->{{ | + | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|3}}}}<!-- |
- | -->{{#ifexpr:{{{2|0}}} <= 4 and {{{2|0}}} + {{{3|0}}} >= 4|<!-- | + | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 4 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 4|<!-- |
- | -->{{ | + | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|4}}}}<!-- |
- | -->{{#ifexpr:{{{2|0}}} <= 5 and {{{2|0}}} + {{{3|0}}} >= 5|<!-- | + | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 5 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 5|<!-- |
- | -->{{ | + | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|5}}}}<!-- |
- | -->{{#ifexpr:{{{2|0}}} <= 6 and {{{2|0}}} + {{{3|0}}} >= 6|<!-- | + | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 6 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 6|<!-- |
- | -->{{ | + | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|6}}}}<!-- |
- | -->{{#ifexpr:{{{2|0}}} <= 7 and {{{2|0}}} + {{{3|0}}} >= 7|<!-- | + | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 7 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 7|<!-- |
- | -->{{ | + | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|7}}}}<!-- |
- | -->{{#ifexpr:{{{2|0}}} <= 8 and {{{2|0}}} + {{{3|0}}} >= 8|<!-- | + | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 8 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 8|<!-- |
- | -->{{ | + | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|8}}}}<!-- |
- | -->{{#ifexpr:{{{2|0}}} <= 9 and {{{2|0}}} + {{{3|0}}} >= 9|<!-- | + | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 9 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 9|<!-- |
- | -->{{ | + | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|9}}}}<!-- |
- | -->{{#ifexpr:{{{2|0}}} <= 10 and {{{2|0}}} + {{{3|0}}} >= 10|<!-- | + | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 10 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 10|<!-- |
- | -->{{ | + | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|10}}}}<!-- |
+ | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 11 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 11|<!-- | ||
+ | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|11}}}}<!-- | ||
+ | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 12 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 12|<!-- | ||
+ | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|12}}}}<!-- | ||
+ | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 13 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 13|<!-- | ||
+ | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|13}}}}<!-- | ||
+ | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 14 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 14|<!-- | ||
+ | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|14}}}}<!-- | ||
+ | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 15 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 15|<!-- | ||
+ | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|15}}}}<!-- | ||
+ | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 16 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 16|<!-- | ||
+ | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|16}}}}<!-- | ||
+ | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 17 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 17|<!-- | ||
+ | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|17}}}}<!-- | ||
+ | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 18 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 18|<!-- | ||
+ | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|18}}}}<!-- | ||
+ | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 19 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 19|<!-- | ||
+ | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|19}}}}<!-- | ||
+ | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 20 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 20|<!-- | ||
+ | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|20}}}}<!-- | ||
+ | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 21 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 21|<!-- | ||
+ | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|21}}}}<!-- | ||
+ | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 22 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 22|<!-- | ||
+ | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|22}}}}<!-- | ||
+ | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 23 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 23|<!-- | ||
+ | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|23}}}}<!-- | ||
+ | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 24 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 24|<!-- | ||
+ | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|24}}}}<!-- | ||
+ | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 25 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 25|<!-- | ||
+ | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|25}}}}<!-- | ||
+ | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 26 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 26|<!-- | ||
+ | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|26}}}}<!-- | ||
+ | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 27 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 27|<!-- | ||
+ | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|27}}}}<!-- | ||
+ | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 28 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 28|<!-- | ||
+ | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|28}}}}<!-- | ||
+ | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 29 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 29|<!-- | ||
+ | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|29}}}}<!-- | ||
+ | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 30 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 30|<!-- | ||
+ | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|30}}}}<!-- | ||
+ | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 31 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 31|<!-- | ||
+ | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|31}}}}<!-- | ||
+ | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 32 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 32|<!-- | ||
+ | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|32}}}}<!-- | ||
+ | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 33 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 33|<!-- | ||
+ | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|33}}}}<!-- | ||
+ | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 34 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 34|<!-- | ||
+ | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|34}}}}<!-- | ||
+ | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 35 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 35|<!-- | ||
+ | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|35}}}}<!-- | ||
+ | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 36 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 36|<!-- | ||
+ | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|36}}}}<!-- | ||
+ | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 37 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 37|<!-- | ||
+ | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|37}}}}<!-- | ||
+ | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 38 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 38|<!-- | ||
+ | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|38}}}}<!-- | ||
+ | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 39 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 39|<!-- | ||
+ | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|39}}}}<!-- | ||
+ | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 40 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 40|<!-- | ||
+ | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|40}}}}<!-- | ||
+ | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 41 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 41|<!-- | ||
+ | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|41}}}}<!-- | ||
+ | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 42 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 42|<!-- | ||
+ | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|42}}}}<!-- | ||
+ | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 43 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 43|<!-- | ||
+ | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|43}}}}<!-- | ||
+ | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 44 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 44|<!-- | ||
+ | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|44}}}}<!-- | ||
+ | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 45 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 45|<!-- | ||
+ | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|45}}}}<!-- | ||
+ | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 46 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 46|<!-- | ||
+ | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|46}}}}<!-- | ||
+ | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 47 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 47|<!-- | ||
+ | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|47}}}}<!-- | ||
+ | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 48 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 48|<!-- | ||
+ | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|48}}}}<!-- | ||
+ | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 49 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 49|<!-- | ||
+ | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|49}}}}<!-- | ||
+ | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} <= 50 and {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}>= 50|<!-- | ||
+ | -->{{{{{subst|}}}strindex|subst={{{subst|}}}|{{{1}}}|50}}}}<!-- | ||
+ | -->{{{{{subst|}}}#ifexpr:{{{2|0}}} > 50 or {{{2|0}}} + {{ #expr: {{{3|0}}} - 1 }}> 50|{{{{{subst|}}}Vorlagenfehler|strsub|Text darf max 50 Zeichen lang sein bzw. Anzahl darf nicht größer 50 sein}}}}<!-- | ||
+ | -->}}</includeonly><noinclude>== Syntax == | ||
+ | <nowiki>{{strsub|</nowiki>''Text''<nowiki>|</nowiki>''Index''<nowiki>|</nowiki>''Anzahl''<nowiki>}}</nowiki> | ||
- | + | == Beschreibung == | |
- | + | Die Vorlage '''strsub''' gibt einen Teil von ''Text'' zurück. ''Index'' legt die Anfangsposition in ''Text'' fest und die Zeichenanzahl wird durch ''Anzahl'' festgelegt. Alle drei Angaben sind Pflichtangaben. | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | == Einschränkung == | |
- | + | Die maximale Länge von ''Text'' ist auf 50 Zeichen beschränkt. Für ''Text'' mit mehr als 50 Zeichen oder ''Anzahl'' größer 50 wird ein Fehler ausgegeben. Diese Vorlage nutzt die Vorlage [[Vorlage:strindex|strindex]] und erbt die dort beschriebene Einschränkung. | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | == Beispiele == | |
- | + | <code><nowiki>{{strsub|</nowiki>''Autobahn''<nowiki>|</nowiki>''1''<nowiki>|</nowiki>''4''<nowiki>}}</nowiki></code> Ergebnis: Auto | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | <code><nowiki>{{strsub|</nowiki>''Autobahn''<nowiki>|</nowiki>''3''<nowiki>|</nowiki>''4''<nowiki>}}</nowiki></code> Ergebnis: toba | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | == Siehe auch == | |
+ | * [[Hilfe:Variablen]] | ||
+ | * [[Hilfe:Vorlagenprogrammierung]] | ||
- | + | [[Kategorie:Vorlage:Funktion|Strsub]] | |
+ | |||
+ | [[en:Template:Str sub]] | ||
+ | </noinclude> |
Aktuelle Version vom 15:37, 9. Dez. 2009
Inhaltsverzeichnis |
Syntax
{{strsub|Text|Index|Anzahl}}
Beschreibung
Die Vorlage strsub gibt einen Teil von Text zurück. Index legt die Anfangsposition in Text fest und die Zeichenanzahl wird durch Anzahl festgelegt. Alle drei Angaben sind Pflichtangaben.
Einschränkung
Die maximale Länge von Text ist auf 50 Zeichen beschränkt. Für Text mit mehr als 50 Zeichen oder Anzahl größer 50 wird ein Fehler ausgegeben. Diese Vorlage nutzt die Vorlage strindex und erbt die dort beschriebene Einschränkung.
Beispiele
{{strsub|Autobahn|1|4}}
Ergebnis: Auto
{{strsub|Autobahn|3|4}}
Ergebnis: toba