This is the documentation page for ಮಾಡ್ಯೂಲ್:String2


The module “String2” contains 4 available calls that convert strings to upper, lower, sentence or title case.

The sentence case function finds the first letter and capitalises that, so it works properly with text containing wiki-markup. Compare {{#invoke:String2|sentence|[[action game]]}} -> Action game with {{ucfirst:{{lc:[[action game]]}}}} -> action game. Piped wiki-links are handled as well: {{#invoke:String2|sentence|[[trimix (breathing gas)|trimix]]}} -> Trimix.

The title case function capitalises the first letter of each word in the text, apart from a number of short words recommended by The U.S. Government Printing Office Style Manual.

Further functions commonly used on strings would be useful additions.

{#invoke:String2 | upper |…}}
{#invoke:String2 | lower |…}}
{#invoke:String2 | sentence |…}}
{#invoke:String2 | title |…}}

Just one unnamed parameter is used, representing the text to be converted to the required case.

Input Output
{{#invoke:String2| upper | abcd }} Script error: The function "upper" does not exist.
{{#invoke:String2| upper | abCD }} Script error: The function "upper" does not exist.
{{#invoke:String2| upper | ABcd }} Script error: The function "upper" does not exist.
{{#invoke:String2| upper | ABCD }} Script error: The function "upper" does not exist.
{{#invoke:String2| upper | }} Script error: The function "upper" does not exist.
 
{{#invoke:String2| lower | abcd }} Script error: The function "lower" does not exist.
{{#invoke:String2| lower | abCD }} Script error: The function "lower" does not exist.
{{#invoke:String2| lower | ABcd }} Script error: The function "lower" does not exist.
{{#invoke:String2| lower | ABCD }} Script error: The function "lower" does not exist.
{{#invoke:String2| lower | }} Script error: The function "lower" does not exist.
 
{{#invoke:String2| sentence | abcd }} Abcd
{{#invoke:String2| sentence | abCD }} Abcd
{{#invoke:String2| sentence | ABcd }} Abcd
{{#invoke:String2| sentence | ABCD }} Abcd
{{#invoke:String2| sentence | [[action game]] }} Action game
{{#invoke:String2| sentence | [[trimix (breathing gas)|trimix]] }} Trimix
{{#invoke:String2 | sentence | {{#invoke:WikidataIB |getValue |P136 |name=genre |fetchwikidata=ALL |qid=Q1396889}} }}
{{#invoke:String2| sentence | }}
 
{{#invoke:String2| title | abcd }} Abcd
{{#invoke:String2| title | abCD }} Abcd
{{#invoke:String2| title | ABcd }} Abcd
{{#invoke:String2| title | ABCD }} Abcd
{{#invoke:String2| title | }}
{{#invoke:String2| title | The Vitamins Are In My Fresh California Raisins}} The Vitamins Are in My Fresh California Raisins

Module:String for the following functions:

  • len
  • sub
  • sublength
  • match
  • pos
  • str_find
  • find
  • replace
  • rep