Template:String-handling templates: Difference between revisions

    From WikiPasokh
    m (1 revision imported)
    (removed false link, not even existing as a redirect)
    Line 9: Line 9:
    | abbr1 = sub
    | abbr1 = sub
    | sect1 = Substring (select chunk of string by its position)
    | sect1 = Substring (select chunk of string by its position)
    | content1 =  {{Aligned table |fullwidth=on |style=text-align:left; |col1width=50%;
    | content1 =  {{Aligned table |fullwidth=on |style=text-align: left; |col1width=50%;
       | {{Aligned table |style=padding-right:2em;
       | {{Aligned table |style=padding-right: 2em;
         |col1style=width:12em;text-align:right;padding-right:0.75em;
         |col1style=width: 12em; text-align: right; padding-right: 0.75em;
         | {{tl|str sub new}} | Select a substring based on starting and ending index counted in either direction.
         | {{tl|str sub new}} | Select a substring based on starting and ending index counted in either direction.
         | {{tl|str left}}      | Keep the first N characters of a string, or duplicate it to N characters.
         | {{tl|str left}}      | Keep the first N characters of a string, or duplicate it to N characters.
    Line 18: Line 18:
         }}
         }}
       | {{Aligned table
       | {{Aligned table
         |col1style=width:12em;text-align:right;padding-right:0.75em;
         |col1style=width: 12em; text-align: right; padding-right: 0.75em;
         | {{tl|str right}}    | Return substring starting at N-th character to end of string.
         | {{tl|str right}}    | Return substring starting at N-th character to end of string.
         | {{tl|str rightc}}    | Return the last N characters of a string; or a given value if empty.
         | {{tl|str rightc}}    | Return the last N characters of a string; or a given value if empty.
    Line 27: Line 27:
    | sect2 = Trimming (select/remove chunk of string by character type)
    | sect2 = Trimming (select/remove chunk of string by character type)
    | content2 =
    | content2 =
    {{Aligned table |fullwidth=on |style=text-align:left; |col1width=50%;
    {{Aligned table |fullwidth=on |style=text-align: left; |col1width=50%;
         | {{Aligned table |style=padding-right:2em;
         | {{Aligned table |style=padding-right: 2em;
           |col1style=width:12em;text-align:right;padding-right:0.75em;
           |col1style=width: 12em; text-align: right; padding-right: 0.75em;
           | {{tl|trim}}                | Trim any leading or trailing whitespace
           | {{tl|trim}}                | Trim any leading or trailing whitespace
           | {{tl|str letter/trim}}    | Trim down to the beginning letters.
           | {{tl|str letter/trim}}    | Trim down to the beginning letters.
    Line 38: Line 38:
           }}
           }}
         | {{Aligned table
         | {{Aligned table
           |col1style=width:12em;text-align:right;padding-right:0.75em;
           |col1style=width: 12em; text-align: right; padding-right: 0.75em;
           | {{tl|string split}}        | Extract a short string from a long string.
           | {{tl|string split}}        | Extract a short string from a long string.
           | {{tl|first word}}          | Trim down to the first space.
           | {{tl|first word}}          | Trim down to the first space.
    Line 50: Line 50:
    | content3 =
    | content3 =
    {{Aligned table |fullwidth=on |style=text-align:left; |col1width=50%;
    {{Aligned table |fullwidth=on |style=text-align:left; |col1width=50%;
         | {{Aligned table |style=padding-right:2em;
         | {{Aligned table |style=padding-right: 2em;
           |col1style=width:12em;text-align:right;padding-right:0.75em;
           |col1style=width: 12em; text-align: right; padding-right: 0.75em;
           | {{tl|delink}}, {{tl|trim brackets}} | Removes wikilink brackets (wikicode); ''all'' or ''outer only''.
           | {{tl|delink}}, {{tl|trim brackets}} | Removes wikilink brackets (wikicode); ''all'' or ''outer only''.
           | {{tl|Plain text}}          | Removes wikicode (formatting and brackets)
           | {{tl|Plain text}}          | Removes wikicode (formatting and brackets)
           | {{tl|PAGENAMEBASE}}        | Trim off any parenthesis text at the end of a string (disambiguation).
           | {{tl|PAGENAMEBASE}}        | Trim off any parenthesis text at the end of a string (disambiguation).
           | {{tl|title disambig text}} | Returns text in parentheses at the end of a string (disambiguation).
           | {{tl|title disambig text}} | Returns text in parentheses at the end of a string (disambiguation).
          | {{tl|WikiProjectbasename}} | Removes "WikiProject" from a pagename.
           }}
           }}
         | {{Aligned table
         | {{Aligned table
           |col1style=width:12em;text-align:right;padding-right:0.75em;
           |col1style=width: 12em; text-align: right; padding-right: 0.75em;
          | {{tl|ship prefix}}        | Returns the length of a ship's name prefix, if listed (ship names).
           | {{tl|title year}}          | Returns the 3-or-4-digit year from a pagename, if any.
           | {{tl|title year}}          | Returns the 3-or-4-digit year from a pagename, if any.
           | {{tl|title decade}}        | Returns the 4-digit decade (e.g. "1740s") from a pagename, if any.
           | {{tl|title decade}}        | Returns the 4-digit decade from a pagename (e.g. "1740" from "Foo 1740s bar"), if any.
           | {{tl|title number}}        | Returns any number from a pagename.
           | {{tl|title number}}        | Returns any number from a pagename.
          | {{tl|WikiProjectbasename}} | Removes "WikiProject" from a pagename.
       }} }}
       }} }}


    Line 70: Line 69:
    | sect4 = Insertion, replacement and length
    | sect4 = Insertion, replacement and length
    | content4 =
    | content4 =
      {{Aligned table |style=margin:0 auto 0;text-align:left;
      {{Aligned table |style=margin: 0 auto 0; text-align: left;
       |  <!---(Insertion, replacement)--->
       |  <!---(Insertion, replacement)--->
         {{Aligned table |style=padding-right:2em;
         {{Aligned table |style=padding-right: 2em;
         |col1style=text-align:right;padding-right:0.75em;
         |col1style=text-align: right; padding-right: 0.75em;
         | {{tl|loop}}          | Repeat character string a specified number of times.
         | {{tl|loop}}          | Repeat character string a specified number of times.
         | {{tl|replace}}      | Returns the string, after replacing ''all'' occurrences of a specified string with another string.
         | {{tl|replace}}      | Returns the string, after replacing ''all'' occurrences of a specified string with another string.
    Line 82: Line 81:
       |  <!---(Length)--->
       |  <!---(Length)--->
         {{Aligned table
         {{Aligned table
         |col1style=text-align:right;padding-right:0.75em;
         |col1style=text-align: right; padding-right: 0.75em;
         | {{tl|str len}}      | Returns a string's length.
         | {{tl|str len}}      | Returns a string's length.
         | {{tl|str ≥ len}}    | Check if a string is "longer or equally long" or "shorter" than a given length.
         | {{tl|str ≥ len}}    | Check if a string is "longer or equally long" or "shorter" than a given length.
    Line 93: Line 92:
    | sect5 = Analysis and searching
    | sect5 = Analysis and searching
    | content5 =
    | content5 =
      {{Aligned table |style=margin:0 auto 0;text-align:left;
      {{Aligned table |style=margin: 0 auto 0; text-align: left;
       |  <!---(Analysis)--->
       |  <!---(Analysis)--->
         {{Aligned table |style=padding-right:2em;
         {{Aligned table |style=padding-right: 2em;
         |col1style=text-align:right;padding-right:0.75em;
         |col1style=text-align: right; padding-right: 0.75em;
         | {{tl|str startswith}}<br>{{tl|str endswith}}  | Check if a string starts or ends with a given string.
         | {{tl|str startswith}}<br>{{tl|str endswith}}  | Check if a string starts or ends with a given string.
         | {{tl|str find}}, {{tl|strfind short}} |style2.2=vertical-align:middle;| Returns the numerical location of a given string in a string.
         | {{tl|str find}}, {{tl|strfind short}} |style2.2=vertical-align:middle;| Returns the numerical location of a given string in a string.
        | {{tl|in string}}    | Returns optional string when given string is not found
         | {{tl|str count}}    | Count the number of occurrences of a pattern within a string.
         | {{tl|str count}}    | Count the number of occurrences of a pattern within a string.
         }}
         }}
       |  <!---(Analysis cont'd)--->
       |  <!---(Analysis cont'd)--->
         {{Aligned table
         {{Aligned table
         |col1style=text-align:right;padding-right:0.75em;
         |col1style=text-align: right; padding-right: 0.75em;
        | {{tl|Array}}        | Array item manipulation and retrieval.
         | {{tl|a or an}}      | Takes a noun and produces the appropriate indefinite article, based on whether the first letter is a vowel.
         | {{tl|a or an}}      | Takes a noun and produces the appropriate indefinite article, based on whether the first letter is a vowel.
         | {{tl|Array}}         | Array manipulation and retrieval.
         | {{tl|in string}}     | Returns optional string when given string is not found
        | {{tl|Font style}}    | Returns bold or italic if the input value has either formatting.
         | {{tl|Isnumeric}}    | Returns number when true, blank when not numeric.
         | {{tl|Isnumeric}}    | Returns number when true, blank when not numeric.
         | {{tl|str letter}}    | Returns the number of letters that begin a string.
         | {{tl|str letter}}    | Returns the number of letters that begin a string.
    Line 120: Line 118:
    |group6=Modules and built-in functions
    |group6=Modules and built-in functions
    |list6={{div col|style=text-align:left}}
    |list6={{div col|style=text-align:left}}
    * [[:Module:String]], [[:Module:String2]], [[:Module:Ustring]], [[Module:Text]]: modules that together contain most necessary string functions.
    * [[:Module:String]], [[:Module:String2]], [[:Module:Ustring]], [[Module:Text]], [[:Template:Navbox wikitext-handling templates|wikitext handling]]: modules that together contain most necessary string functions.
    * [[mw:Help:Magic words|Magic words]]: About <code><nowiki>{{padleft:&#124;}}</nowiki></code>, <code><nowiki>{{lc:&#124;}}</nowiki></code>,  <code><nowiki>{{formatnum:&#124;}}</nowiki></code> etc.
    * [[mw:Help:Magic words|Magic words]]: About <code><nowiki>{{padleft:&#124;}}</nowiki></code>, <code><nowiki>{{lc:&#124;}}</nowiki></code>,  <code><nowiki>{{formatnum:&#124;}}</nowiki></code> etc.
    * [[mw:Help:Extension:ParserFunctions|ParserFunctions]]: About <code><nowiki>{{#titleparts:&#124;}}, {{#expr:&#124;}}, {{#ifeq:&#124;}}, </nowiki></code> etc.{{div col end}}
    * [[mw:Help:Extension:ParserFunctions|ParserFunctions]]: About <code><nowiki>{{#titleparts:&#124;}}, {{#expr:&#124;}}, {{#ifeq:&#124;}}, </nowiki></code> etc.{{div col end}}
    Line 131: Line 129:
    ** [[:m:Category:String manipulation templates|Meta-Wiki]]
    ** [[:m:Category:String manipulation templates|Meta-Wiki]]
    ** [[:d:Category:String manipulation templates|Wikidata]]
    ** [[:d:Category:String manipulation templates|Wikidata]]
    * [[:Category:Modules that manipulate strings|Category:String manipulating modules]]
    * [[:Category:Modules that manipulate strings]]
    | tracking = no <!--(keep all these string templates (by /doc pages) out of the tracking category)-->
    | tracking = no <!--(keep all these string templates (by /doc pages) out of the tracking category)-->


    }}<noinclude>{{documentation}}</noinclude>
    }}<noinclude>{{documentation}}</noinclude>

    Revision as of 17:52, 2 September 2024