FANDOM


2

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

Template:Documentation subpage Template:Lua

Usage

Template:Tlc

Returns the position of first appearance of sub_string in text.

  • The comparison is case sensitive.
  • Returns -1 if sub_string not found
  • Character position is 1 based (not 0 based as usual in calculations).
  • Template:Color This case will often have to be handled specially.

Examples

In the examples, the string to be searched is Template:Code:

  • A; -1
  • a; -1
  • def; -1
  • klm; -1
  • zyx; -1
  • empty;klm;-1
  • empty;empty; 2

TemplateData

Template:TemplateDataHeader <templatedata> {

       "description": "A template to find the numeric position of first appearance of sub_string in text",
       "params": {
               "1": {
                       "label": "Text",
                       "description": "The text to search within",
                       "type": "string",
                       "required": true
               },
               "2": {
                       "label": "Sub_string",
                       "description": "The string to be searched within the text",
                       "type": "string",
                       "required": true
               }
       }

} </templatedata>

See also

Template:String-handling templates

This page uses material from the Wikipedia page Template:Str find, which is released under the Creative Commons Attribution-ShareAlike 3.0 Unported License (view authors). Wikipedia-logo-v2
Community content is available under CC-BY-SA unless otherwise noted.