Pāriet uz saturu

Veidne:Posnq

Vikipēdijas lapa
Dokumentācijas ikona Veidnes dokumentācija[skatīt] [labot] [hronoloģija] [pārlādēt]

Wrapper template for function posnq in Module:String2.

  • posnq (position, no quotes) returns the numerical start position of the first occurrence of one piece of text ("target") inside another ("source"). UTC characters are supported.
  • It returns nil by default if no match is found, or if either parameter is blank. If no match is found it can return the value of an optional "nomatch" parameter.
  • It takes the text to be searched in as the first unnamed parameter (or |source=), which is trimmed.
  • It takes the text to match as the second unnamed parameter (or |target=), which is trimmed and any double quotes " are stripped out. That allows spaces at the beginning or end of the match string to be included in a consistent manner.
  • It can take an optional third unnamed parameter (or |plain=), which is trimmed. If it's set to false, then the search accepts Lua pattern-matching for the target, otherwise a plain search is used.
  • It can take an optional fourth unnamed parameter (or |nomatch=), which is trimmed. This value is returned if no match occurs. Setting |nomatch=0 makes the output compatible with the find function in Module:String.

Examples

[labot pirmkodu]
  • {{Posnq |This is a piece of text to be searched |piece of }} → 11
  • {{Posnq |This is a piece oftext to be searched |piece of }} → 11
  • {{Posnq |This is a piece of text to be searched |"piece of "}} → 11
  • {{Posnq |This is a piece oftext to be searched |"piece of "}}
  • {{posnq |This is a piece of text to be searched |ext}} → 21
  • {{posnq |This is a piece of text to be searched |ent}}
  • {{posnq |This is a piece of text to be searched |" pie"}} → 10
  • {{posnq |This is a piece of text to be searched |" ece"}}
  • {{posnq |source=This is a piece of text |target=ece}} → 13
  • {{posnq |source=This is a piece of text |target=%s |plain=true}}
  • {{posnq |source=This is a piece of text |target=%s |plain=false}} → 5
  • {{posnq |source=This is a piece of text |target=ece |nomatch=0}} → 13
  • {{posnq |source=This is a piece of text |target=xyz |nomatch=0}} → 0
  • {{posnq |This is a piece of text |" of" |true |0}} → 16
  • {{posnq |This is a piece of text |" of" |true |0}} → 0
  • {{posnq |source=Meet at Café Nero |target=afé}} → 10

Veidne:Sandbox other