Пређи на садржај

Шаблон:Str find0

Iz Vojne Enciklopedije

{{#expr:0 - 1}}

Документација шаблона[прикажи] [уреди] [историја] [освежи]

{{#ifeq:str find0 |док

    | 

{{#ifeq:show |show

|
        }}{{#if: |
         |   {{#ifexist:Шаблон:Str find0
                  | [[Категорија:Документација {{#switch:Шаблон |Шаблон=шаблона |Модул=модула |Корисник=корисничких страница |#default=Википедије}}]]
                  | 
                 }}
        }}
    | 
   }}

The Template:str_find0 returns first appearance of a substring in a string, otherwise returns -1.
This template uses sub-template:str sub find which does the routine.

Usage

{{{{#if: |замени:}}str find0{{#if:<string1> ||<string1>}}{{#if:<string2> ||<string2>}}{{#if: ||{{{4}}}}}{{#if: ||{{{5}}}}}{{#if: ||{{{6}}}}}{{#if: ||{{{7}}}}}{{#if: ||{{{8}}}}}{{#if: ||{{{9}}}}}{{#if: ||{{{10}}}}}{{#if: ||{{{11}}}}}{{#if: ||{{{12}}}}}{{#if: ||{{{13}}}}}{{#if: ||{{{14}}}}}{{#if: ||{{{15}}}}}{{#if: ||{{{16}}}}}{{#if: ||{{{17}}}}}{{#if: ||{{{18}}}}}{{#if: ||{{{19}}}}}{{#if: ||{{{20}}}}}{{#if: ||...}}}}

  • It is zero-based. So no need for extra {{#expr:{{str find|}}-1}} calculations to use it in other templates.

Limitations

  • Handles strings up to 90 characters.

Performance

  • Very fast on short strings. Uses enhanced algorithm to run the subroutine only when needed.

Examples

  • {{str find0|abcdef|abc}} → {{#expr:1 - 1}}
  • {{str find0|abcdef|def}} → {{#expr:4 - 1}}
  • {{str find0|abcdef|ghi}} → {{#expr:0 - 1}}
  • {{str find0|abcdef|abcdefghi}} → {{#expr:0 - 1}}

See also