Vorlage:Str mid: Unterschied zwischen den Versionen

more generic, allow negative substr length
(Undid revision 541209234 by DePiep (talk) not that easy.)
(more generic, allow negative substr length)
Zeile 1: Zeile 1:
{{#invoke:String|sub|s={{{1|}}}|i={{#if:{{{2|}}}|{{{2|}}}|1}}|j={{#if:{{{j|}}}|{{{j|}}}|{{#if:{{{3|}}}|{{#expr:{{#if:{{{2|}}}|{{{2|}}}|1}}+{{{3|0}}}-1}}|{{str len|{{{1|}}}}}}}}}|ignore_errors={{{ignore errors|false}}}|{{#if:{{{error category|}}}|error_category={{{error category|}}}}}|no_category={{{no category|false}}}}}<noinclude>
{{str mid/core
| s={{{1|}}}
| i={{#if:{{{i|{{{2|}}}}}}|{{{i|{{{2|}}}}}}|{{#ifexpr:({{#if:{{{3|}}}|1|0}} and {{#if:{{{j|{{{4|}}}}}}|1|0}})|{{#expr:{{{j|{{{4|}}}}}}-{{{3|}}}+{{#ifexpr:{{{3|}}}<0|-1|1}}}}|1}}}}
| j={{#if:{{{j|{{{4|}}}}}}|{{{j|{{{4|}}}}}}|{{#if:{{{3|}}}|{{#expr:{{#if:{{{i|{{{2|}}}}}}|{{{i|{{{2|}}}}}}|1}}+{{{3|}}}+{{#ifexpr:{{{3|}}}<0|1|-1}}}}|{{#invoke:String|len|{{trim|{{{1|}}}}}}}}}}}
| slen={{#invoke:String|len|{{trim|{{{1|}}}}}}}
| sublen={{formatnum:{{{3|}}}}}
| invert={{#ifexpr:{{formatnum:{{#ifeq:{{{3|}}}||0|{{{3|}}}}}}}<0|yes|no}}
| triangle check={{#if:{{{i|{{{2|}}}}}}|{{#if:{{{3|}}}|{{#if:{{{j|{{{4|}}}}}}|{{#ifexpr:(({{{j|{{{4|0}}}}}}-{{{i|{{{2|0}}}}}}+1)<>{{{3|0}}}) and ({{{i|{{{2|}}}}}}*{{{j|{{{4|}}}}}}<>0)|Error using {{tl|Str mid}}: indexes i={{{i|{{{2|}}}}}} and j={{{j|{{{4|}}}}}} do not match requested substring length {{{3|}}}}}|}}}}}}
|ignore_errors={{{ignore errors|false}}}
|error_category={{yesno|{{{error category|}}}|yes={{{error category|}}}}}
|no_category={{{no category|false}}}}}<noinclude>
{{documentation}}
{{documentation}}
</noinclude>
</noinclude>
Anonymer Benutzer