Template:Str find0

-1

Template documentation[view] [edit] [history] [purge]

The Template:str_find0 returns first appearance of a substring in a string, otherwise returns -1.

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.

Identical to {{#expr:{{#invoke:String|find|source={{{1}}}|target={{{2}}}}} - 1}}

Examples

  • {{str find0|abcdef|abc}} → 0
  • {{str find0|abcdef|def}} → 3
  • {{str find0|abcdef|ghi}} → -1
  • {{str find0|abcdef|abcdefghi}} → -1

See also