Template:Str find0
-1
File:Lua-logo-nolabel.svg|30px|alt=Lua logo|link=Wikipedia:Lua | Uses Lua:
|
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
{{str find0|<string1>|<string2>}}
- 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}} → 0
- {{str find0|abcdef|def}} → 3
- {{str find0|abcdef|ghi}} → -1
- {{str find0|abcdef|abcdefghi}} → -1
See also
- Template:Str find - 1-based string searching template.
- Template:Strfind short - rapidly finds string in expansion depth 6 rather than 21
Script error: The function "navbox" does not exist.
bn:টেমপ্লেট:Str find0 lv:Veidne:Str find0
The above documentation is transcluded from Template:Str find0/doc. (edit | history) Editors can experiment in this template's sandbox (create | mirror) and testcases (create) pages. Please add categories to the /doc subpage. Subpages of this template. |