Fyrimynd:Str find0

Frá Wikipedia, hin frælsa alfrøðin
Far til: navigatión, leita

-1

Documentation icon Skjalfesting til fyrimyndina[vís] [rætta] [søga] [dagfør]

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[rætta wikitekst]

{{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[rætta wikitekst]

  • Handles strings up to 90 characters.

Performance[rætta wikitekst]

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

Examples[rætta wikitekst]

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

See also[rætta wikitekst]