Jump to content

Teamplaid:Str find0/documentation

O Wiktionary

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

Ùsaid - Usage

[deasaich]

{{Str find0|<string1>|<string2>}}

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

Crìochan - Limitations

[deasaich]
  • Handles strings up to 90 characters.

Coileanadh - Performance

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

Eisimpleirean - Examples

[deasaich]
  • {{Str find0|abcdef|abc}} → 0
  • {{Str find0|abcdef|def}} → 3
  • {{Str find0|abcdef|ghi}} → -1
  • {{Str find0|abcdef|abcdefghi}} → -1
  • {{Str find0|abcdef|efg}} → -1

Faic cuideachd - Also see