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

Template:Documentation subpage Template:Lua



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.


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


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.