| i={{#if:{{{2|}}}}|{{{2|}}}|{{#ifexpr:({{#if:{{{3|}}}|1|0}} and {{#if:{{{4|}}}|1|0}})|{{#expr:{{min|{{{4|}}}|{{str len|{{trim|{{{1|}}}}}}}}}-{{{3|}}}+{{#ifexpr:{{{3|}}}<0|-1|1}}}}|1}}}}
| triangle check={{#if:{{{2|}}}|{{#if:{{{3|}}}|{{#if:{{{4|}}}|{{#ifexpr:(({{{4|}}}-{{{2|0}}}+1)<>{{{3|0}}}) and ({{{2|}}}*{{{4|}}}<>0)|Error using {{tl|Str mid}}: indexes i={{{2|}}} and j={{{4|}}} do not match requested substring length {{trim|{{{3|}}}}}}}|}}}}}}