Module:String2/doc: Difference between revisions

Content deleted Content added
Posnq: Deleted at TfD
Line 50:
| List missing || <code><nowiki>{{#invoke:String2 |findlast |}}</nowiki></code> || {{#invoke:String2 |findlast |}}
|}
 
=== posnq ===
* 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 {{para|source}}), which is trimmed.
* It takes the text to match as the second unnamed parameter (or {{para|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 {{para|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 {{para|nomatch}}), which is trimmed. This value is returned if no match occurs. Setting {{para|nomatch|0}} makes the output compatible with the find function in [[Module:String]].
; Examples
: <code><nowiki>{{#invoke:String2 |posnq |This is a piece of text to be searched |ext}}</nowiki></code> → {{#invoke:String2 |posnq |This is a piece of text to be searched |ext}}
: <code><nowiki>{{#invoke:String2 |posnq |This is a piece of text to be searched |ent}}</nowiki></code> → {{#invoke:String2 |posnq |This is a piece of text to be searched |ent}}
: <code><nowiki>{{#invoke:String2 |posnq |This is a piece of text to be searched |" pie"}}</nowiki></code> → {{#invoke:String2 |posnq |This is a piece of text to be searched |" pie"}}
: <code><nowiki>{{#invoke:String2 |posnq |This is a piece of text to be searched |" ece"}}</nowiki></code> → {{#invoke:String2 |posnq |This is a piece of text to be searched |" ece"}}
: <code><nowiki>{{#invoke:String2 |posnq |source=This is a piece of text |target=ece}}</nowiki></code> → {{#invoke:String2 |posnq |source=This is a piece of text |target=ece}}
: <code><nowiki>{{#invoke:String2 |posnq |source=This is a piece of text |target=%s |plain=true}}</nowiki></code> → {{#invoke:String2 |posnq |source=This is a piece of text |target=%s |plain=true}}
: <code><nowiki>{{#invoke:String2 |posnq |source=This is a piece of text |target=%s |plain=false}}</nowiki></code> → {{#invoke:String2 |posnq |source=This is a piece of text |target=%s |plain=false}}
: <code><nowiki>{{#invoke:String2 |posnq |source=This is a piece of text |target=ece |nomatch=0}}</nowiki></code> → {{#invoke:String2 |posnq |source=This is a piece of text |target=ece |plain=false |nomatch=0}}
: <code><nowiki>{{#invoke:String2 |posnq |source=This is a piece of text |target=xyz |nomatch=0}}</nowiki></code> → {{#invoke:String2 |posnq |source=This is a piece of text |target=xyz |nomatch=0}}
: <code><nowiki>{{#invoke:String2 |posnq |This is a piece of text |" of" |true |0}}</nowiki></code> → {{#invoke:String2 |posnq |This is a piece of text |" of" |true |0}}
: <code><nowiki>{{#invoke:String2 |posnq |This is a piece of text |" of" |true |0}}</nowiki></code> → {{#invoke:String2 |posnq |This is a piece of text |" of" |true |0}}
: <code><nowiki>{{#invoke:String2 |posnq |source=Meet at Café Nero |target=afé}}</nowiki></code> → {{#invoke:String2 |posnq |source=Meet at Café Nero |target=afé}}
 
=== split ===