Content deleted Content added
add usage and examples |
+Cat |
||
(7 intermediate revisions by 5 users not shown) | |||
Line 15:
=== title ===
The title function capitalises the first letter of each word in the text, apart from a number of short words
This is a very simplistic algorithm; see [[:Template:Title case/doc]] for some of its limitations.
=== sentence ===
Line 65 ⟶ 67:
The index parameter is optional; it defaults to the first chunk of text.
The
=== stripZeros ===
Line 85 ⟶ 87:
* First positional parameter or |text is the text to be searched for.
* Optional parameter |title is the page title, defaults to the current page.
* Optional parameter |plain is either true for a plain search (default), or false for a [[mw:Extension:Scribunto/Lua reference manual #Patterns|Lua pattern]] search.
* Optional parameter |nomatch is the value returned when no match is found; default is nothing.
Line 105 ⟶ 107:
; Usage
: <code><nowiki>{{#invoke:String2|strip|</nowiki><var>source_string</var>|<var>characters_to_strip
: <code><nowiki>{{#invoke:String2|strip|
; Examples
: <code><nowiki>{{#invoke:String2|strip|abc123def|123}}</nowiki></code> → {{#invoke:String2|strip|abc123def|123}}
: <code><nowiki>{{#invoke:String2|strip|abc123def|123|true}}</nowiki></code> → {{#invoke:String2|strip|abc123def|123|true}}▼
: <code><nowiki>{{#invoke:String2|strip|abc123def|%d+|false}}</nowiki></code> → {{#invoke:String2|strip|abc123def|%d+|false}}
▲: <code><nowiki>{{#invoke:String2|strip|source=abc123def|chars=123
: <code><nowiki>{{#invoke:String2|strip|source=abc123def|chars=%d+|plain=false}}</nowiki></code> → {{#invoke:String2|strip|source=abc123def|chars=%d+|plain=false}}
=== matchAny ===
Line 145 ⟶ 148:
A startswith function similar to {{ml|string|endswith}}. Both parameters are required, although they can be blank. Leading and trailing whitespace ''is'' counted, use named parameters to avoid this if required. Outputs "yes" for true and blank for false so may be passed directly to #if.
{{markup|padding=1px 5px|
<nowiki>{{#invoke:string2|startswith|search|se}}</nowiki>|{{#invoke:string2|startswith|search|se}}|
<nowiki>{{#invoke:string2|startswith|search|ch}}</nowiki>|{{#invoke:string2|startswith|search|ch}}}}<!-- Template:Mra -->
===isnumeric===
Implements {{tl|isnumeric}}, which tests whether a value is numeric (or at least, that it can be treated as such by the [[:mw:Extension:Scribunto/Lua_reference_manual#Language_library|Scribunto language library]]). By default, it will pass through the parameter if it's numeric and be blank if it's not. If the parameter <code>boolean=true</code> is given, then it will output <code>1</code> if numeric and <code>0</code> if not numeric.
{{markup|padding=1px 5px|
<nowiki>{{#invoke:string2|isnumeric|1,327.50}}</nowiki>|{{#invoke:string2|isnumeric|1,327.50}}|
<nowiki>{{#invoke:string2|isnumeric|9,999 (1950)}}</nowiki>|{{#invoke:string2|isnumeric|9,999 (1950)}}|
<nowiki>{{#invoke:string2|isnumeric|1,327.50|boolean=true}}</nowiki>|{{#invoke:string2|isnumeric|1,327.50|boolean=true}}|
<nowiki>{{#invoke:string2|isnumeric|9,999 (1950)|boolean=true}}</nowiki>|{{#invoke:string2|isnumeric|9,999 (1950)|boolean=true}}}}
== Usage ==
Line 292 ⟶ 304:
<includeonly>{{Sandbox other||
[[Category:Modules that manipulate strings|*]]
[[Category:Template metamodules]]
}}</includeonly>
|