Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Humanipedia
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Module:String2/doc
(section)
Module
Discussion
English
Read
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Examples == {| class="wikitable" ! scope="col" | Input ! scope="col" | Output |- | <nowiki>{{#invoke:String2| ucfirst | abcd }}</nowiki> | {{#invoke:String2| ucfirst | abcd }} |- | <nowiki>{{#invoke:String2| ucfirst | abCD }}</nowiki> | {{#invoke:String2| ucfirst | abCD }} |- | <nowiki>{{#invoke:String2| ucfirst | ABcd }}</nowiki> | {{#invoke:String2| ucfirst | ABcd }} |- | <nowiki>{{#invoke:String2| ucfirst | ABCD }}</nowiki> | {{#invoke:String2| ucfirst | ABCD }} |- | <nowiki>{{#invoke:String2| ucfirst | 123abcd }}</nowiki> | {{#invoke:String2| ucfirst | 123abcd }} |- | <nowiki>{{#invoke:String2| ucfirst | }}</nowiki> | {{#invoke:String2| ucfirst | }} |- | <nowiki>{{#invoke:String2| ucfirst | human X chromosome }}</nowiki> | {{#invoke:String2| ucfirst | human X chromosome}} |- | <nowiki>{{#invoke:String2 | ucfirst | {{#invoke:WikidataIB |getValue</nowiki><br /><nowiki>| P136 |fetchwikidata=ALL |onlysourced=no |qid=Q1396889}} }}</nowiki> | {{#invoke:String2 | ucfirst | {{#invoke:WikidataIB |getValue |P136 |fetchwikidata=ALL |onlysourced=no |qid=Q1396889}} }} |- | <nowiki>{{#invoke:String2 | ucfirst | {{#invoke:WikidataIB |getValue</nowiki><br /><nowiki>| P106 |fetchwikidata=ALL |list=hlist |qid=Q453196}} }}</nowiki> | {{#invoke:String2 | ucfirst | {{#invoke:WikidataIB |getValue |P106 |fetchwikidata=ALL |list=hlist |qid=Q453196}} }} |- | | |- | <nowiki>{{#invoke:String2| sentence | abcd }}</nowiki> | {{#invoke:String2| sentence | abcd }} |- | <nowiki>{{#invoke:String2| sentence | abCD }}</nowiki> | {{#invoke:String2| sentence | abCD }} |- | <nowiki>{{#invoke:String2| sentence | ABcd }}</nowiki> | {{#invoke:String2| sentence | ABcd }} |- | <nowiki>{{#invoke:String2| sentence | ABCD }}</nowiki> | {{#invoke:String2| sentence | ABCD }} |- | <nowiki>{{#invoke:String2| sentence | [[action game]] }}</nowiki> | {{#invoke:String2| sentence | [[action game]] }} |- | <nowiki>{{#invoke:String2| sentence | [[trimix (breathing gas)|trimix]] }}</nowiki> | {{#invoke:String2| sentence | [[trimix (breathing gas)|trimix]] }} |- | <nowiki>{{#invoke:String2| sentence | }}</nowiki> | {{#invoke:String2| sentence | }} |- | | |- | <nowiki>{{#invoke:String2| title | abcd }}</nowiki> | {{#invoke:String2| title | abcd }} |- | <nowiki>{{#invoke:String2| title | abCD }}</nowiki> | {{#invoke:String2| title | abCD }} |- | <nowiki>{{#invoke:String2| title | ABcd }}</nowiki> | {{#invoke:String2| title | ABcd }} |- | <nowiki>{{#invoke:String2| title | ABCD }}</nowiki> | {{#invoke:String2| title | ABCD }} |- | <nowiki>{{#invoke:String2| title | }}</nowiki> | {{#invoke:String2| title | }} |- | <nowiki>{{#invoke:String2| title | the vitamins are in my fresh california raisins}}</nowiki> | {{#invoke:String2| title | the vitamins are in my fresh california raisins}} |- |} === String split === [[Template:String split]] is a convenience wrapper for the split function. * <code><nowiki>{{String split |This is a piece of text to be split |" "}}</nowiki></code> β {{String split |This is a piece of text to be split |" "}} * <code><nowiki>{{String split |This is a piece of text to be split |" "| 4}}</nowiki></code> β {{String split |This is a piece of text to be split |" "| 4}} * <code><nowiki>{{String split |This is a piece of text to be split |x| 2}}</nowiki></code> β {{String split |This is a piece of text to be split |x| 2}} Modules may return strings with | as separators like this: <code><nowiki>{{#invoke:carousel | main | name = WPDogs | switchsecs = 5 }}</nowiki></code> β {{#invoke:carousel | main | name = WPDogs | switchsecs = 5 }} * <code><nowiki>{{String split |{{#invoke:carousel | main | name = WPDogs | switchsecs = 5 }}|{{!}}| 2}}</nowiki></code> β {{String split |{{#invoke:carousel | main | name = WPDogs | switchsecs = 5 }}|{{!}}| 2}} Lua patterns can allow splitting at classes of characters such as punctuation: * <code><nowiki>{{String split |Apples, pears, oranges; Cats, dogs|"%p"| 2 |false}}</nowiki></code> β {{String split |Apples, pears, oranges; Cats, dogs|"%p"| 2 |false}} * <code><nowiki>{{String split |Apples, pears, oranges; Cats, dogs|"%p"| 4 |false}}</nowiki></code> β {{String split |Apples, pears, oranges; Cats, dogs|"%p"| 4 |false}} Or split on anything that isn't a letter (no is treated as false): * <code><nowiki>{{String split |Apples pears oranges; Cats dogs|"%A+"| 4 |no}}</nowiki></code> β {{String split |Apples pears oranges; Cats dogs|"%A+"| 4 |no}} Named parameters force the trimming of leading and trailing spaces in the parameters and are generally clearer when used: * <code><nowiki>{{String split | txt=Apples pears oranges; Cats dogs | sep="%A+" | idx=3 | plain=false }}</nowiki></code> β {{String split | txt=Apples pears oranges; Cats dogs | sep="%A+" | idx=3 | plain=false }} === One2a === [[Template:One2a]] is a convenience wrapper for the one2a function. Capitalisation is kept. Aimed for usage with {{tl|Convert}}. * <code><nowiki>{{one2a |One foot. One mile. One kilometer. One inch.One amp. one foot. one mile. one inch. Alone at last. Onely the lonely. ONE ounce. One monkey.}}</nowiki></code> β :{{one2a |One foot. One mile. One kilometer. One inch.One amp. one foot. one mile. one inch. Alone at last. Onely the lonely. ONE ounce. One monkey.}} * <code><nowiki>{{convert|1|ft|spell=on}}</nowiki></code> β {{convert|1|ft|spell=on}} * <code><nowiki>{{one2a|{{convert|1|ft|spell=on}}}}</nowiki></code> β {{one2a|{{convert|1|ft|spell=on}}}} * <code><nowiki>{{convert|2.54|cm|0|disp=out|spell=on}}</nowiki></code> β {{convert|2.54|cm|0|disp=out|spell=on}} * <code><nowiki>{{one2a|{{convert|2.54|cm|0|disp=out|spell=on}}}}</nowiki></code> β {{one2a|{{convert|2.54|cm|0|disp=out|spell=on}}}}
Summary:
Please note that all contributions to Humanipedia may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Humanipedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)