Template:String-handling templates: Difference between revisions

From escforumwiki
Jump to navigation Jump to search
m (1 revision imported)
 
en>Guarapiranga
(→‎Template:Str_left: Redundant, out of the std with the rest)
Line 1: Line 1:
{{Navbox with collapsible groups
{{#invoke:Navbox with collapsible groups|navbox
| name = String-handling templates
| name = String-handling templates
| state = {{{state|expanded}}}
| state = {{{state|expanded}}}
| bodyclass = plainlist
| bodyclass = plainlist
| title = String-handling templates
| title = String-handling templates [[Help:Manipulating_strings|(help page)]]
| selected = {{{selected|{{{expanded|{{{1|}}}}}}}}}
| selected = {{{selected|{{{expanded|{{{1|}}}}}}}}}


<!---------------------- Trimming ------------------------->
<!---------------------- Trimming ------------------------->
| abbr1 = trim
| abbr1 = sub
| sect1 = [[Trimming (computer programming)|Trimming]]
| sect1 = Substring (select chunk of string by its position)
| content1 =
| content1 =  {{Aligned table |fullwidth=on |style=text-align:left; |col1width=50%;
{{Navbox |child
  | {{Aligned table |style=padding-right:2em;
    |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 left}}      | Keep the first N characters of a string, or duplicate it to N characters.
    | {{tl|str crop}}      | Return all but the last N characters of a string.
    | {{tl|str index}}    | Return the N-th character of a string.
    }}
  | {{Aligned table
    |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 rightc}}    | Return the last N characters of a string; or a given value if empty.
    | {{tl|str sub old}}  | Return substring of given length starting at N-th character.
}} }}


  | group1 = By counting
| abbr2 = trim
  | list1 =
| sect2 = Trimming (select/remove chunk of string by character type)
  {{Aligned table |fullwidth=on |style=text-align:left; |col1width=50%;
| content2 =
     | {{Aligned table |style=padding-right:2.5em;
{{Aligned table |fullwidth=on |style=text-align:left; |col1width=50%;
       |col1style=width:12.5em;text-align:right;white-space:nowrap;padding-right:0.75em; |col2style=font-style:italic;
     | {{Aligned table |style=padding-right:2em;
       | {{tl|str mid}}       | To return a substring specified by position and length.
       |col1style=width:12em;text-align:right;padding-right:0.75em;
       | {{tl|trunc}}         | To trim down to a specified number of characters.
      | {{tl|trim}}                | Trim any leading or trailing whitespace
       | {{tl|str left}}     | To trim down to a specified number of characters or duplicate the string to a specified number.
       | {{tl|str letter/trim}}     | Trim down to the beginning letters.
       | {{tl|str crop}}     | To crop a specified number of characters off the end.
       | {{tl|str number/trim}}     | Trim down to the beginning numbers.
       | {{tl|chop head and tail}} | To crop a specified number of characters off the beginning and end.
       | {{tl|trim brackets}}       | Trim any leading or trailing square brackets.
       | {{tl|trim quotes}}         | Trim leading or trailing matching quotes.
       | {{tl|trim leading}}       | Trim up to six instances of specified <prefix>.
       }}
       }}
     | {{Aligned table
     | {{Aligned table
       |col1style=width:12.5em;text-align:right;white-space:nowrap;padding-right:0.75em; |col2style=font-style:italic;
       |col1style=width:12em;text-align:right;padding-right:0.75em;
       | {{tl|str right}}     | To trim the first specified number of characters.
       | {{tl|string split}}        | Extract a short string from a long string.
       | {{tl|str rightc}}    | To return a number of characters from the end, returns a parameter if the string is empty.
       | {{tl|first word}}         | Trim down to the first space.
       | {{tl|str rightmost}} | To trim down to the last specified number of characters.
       | {{tl|remove first word}}  | Remove anything before the first space.
       | {{tl|str sub old}}  | To trim down to a specified number, starting at a given number from the left.
       | {{tl|last word}}           | Trim down from the last space.
       | {{tl|str sub new}}   | Select a substr based on starting and ending index.
       | {{tl|remove last word}}   | Remove anything after the last space.
       | {{tl|str index}}     | Returns a given character from a string, but not accented letters.
}} }}
  }} }}


  | group2 = By checking
| abbr3 = specific
  | list2 =
| group3 = Select/remove specific item from string
  {{Aligned table |fullwidth=on |style=text-align:left; |col1width=50%;
| content3 =
     | {{Aligned table |style=padding-right:2.5em;
{{Aligned table |fullwidth=on |style=text-align:left; |col1width=50%;
       |col1style=width:12.5em;text-align:right;white-space:nowrap;padding-right:0.75em; |col2style=font-style:italic;
     | {{Aligned table |style=padding-right:2em;
       | {{tl|trim}}                | To trim any leading or trailing whitespace
       |col1style=width:12em;text-align:right;padding-right:0.75em;
      | {{tl|str letter/trim}}    | To trim down to the beginning letters.
       | {{tl|delink}}, {{tl|trim brackets}} | Removes wikilink brackets (wikicode); ''all'' or ''outer only''.
      | {{tl|str number/trim}}     | To trim down to the beginning numbers.
       | {{tl|Plain text}}         | Removes wikicode (formatting and brackets)
      | {{tl|trim brackets}}       | To trim any leading or trailing square brackets.
       | {{tl|PAGENAMEBASE}}        | Trim off any parenthesis text at the end of a string (disambiguation).
      | {{tl|trim quotes}}        | To trim leading or trailing matches quotes.
      }}
    | {{Aligned table
      |col1style=width:12.5em;text-align:right;white-space:nowrap;padding-right:0.75em; |col2style=font-style:italic;
      | {{tl|first word}}          | To trim down to the first space.
      | {{tl|remove first word}}  | To remove anything before the first space.
      | {{tl|last word}}          | To trim down from the last space.
      | {{tl|remove last word}}    | To remove anything after the last space.
  }} }}
 
  | group3 = Dedicated
  | list3 =
  {{Aligned table |fullwidth=on |style=text-align:left; |col1width=50%;
    | {{Aligned table |style=padding-right:2.5em;
      |col1style=width:12.5em;text-align:right;white-space:nowrap;padding-right:0.75em; |col2style=font-style:italic;
      | {{tl|delink}}              | Removes wikilink brackets (wikicode).
       | {{tl|remove file prefix}} | Removes "File:" (or "Image:") from filenames.
       | {{tl|PAGENAMEBASE}}        | To 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:12.5em;text-align:right;white-space:nowrap;padding-right:0.75em; |col2style=font-style:italic;
       |col1style=width:12em;text-align:right;padding-right:0.75em;
      | {{tl|WikiProjectbasename}} | Removes "WikiProject" from a pagename.
      | {{tl|remove unranked}}    | Removes the string "unranked_" from the left of a string (taxonomy).
       | {{tl|ship prefix}}        | Returns the length of a ship's name prefix, if listed (ship names).
       | {{tl|ship prefix}}        | Returns the length of a ship's name prefix, if listed (ship names).
       | {{tl|title year}}          | Returns the 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 number}}        | Returns any number from a pagename.
   }} }}
   }} }}
}}


<!----------- Insertion, replacement, length -------------->
<!----------- Insertion, replacement, length -------------->
| abbr2 = IRL
| abbr4 = IRL
| sect2 = Insertion, replacement and length
| sect4 = Insertion, replacement and length
| content2 =
| 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:2.5em;
     {{Aligned table |style=padding-right:2em;
     |col1style=text-align:right;white-space:nowrap;padding-right:0.75em; |col2style=font-style:italic;
     |col1style=text-align:right;padding-right:0.75em;
    | {{tl|strloc insert}} | Inserts a string at character location strloc, or appends if strloc<{{=}}0.
     | {{tl|loop}}          | Repeat character string a specified number of times.
     | {{tl|loop}}          | Repeat character string a specified number of times.
    | {{tl|repeat}}        | Repeat a 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.
     | {{tl|str rep}}      | Returns the string, after replacing the first occurrence of a specified string with another string.
     | {{tl|str rep}}      | Returns the string, after replacing the first occurrence of a specified string with another string.
     | {{tl|digits}}        | Returns the string, after removing all characters that are not digits 0–9
     | {{tl|digits}}        | Returns the string, after removing all characters that are not digits 0–9
    | {{tl|Nowiki}}        | Displays wikitext as plain text.
     }}
     }}
   |  <!---(Length)--->
   |  <!---(Length)--->
     {{Aligned table
     {{Aligned table
     |col1style=text-align:right;white-space:nowrap;padding-right:0.75em; |col2style=font-style:italic;
     |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|iflenge}}      | [if len]gth [g]reater than or [e]qual to.
     | {{tl|str ≥ len}}    | Check if a string is "longer or equally long" or "shorter" than a given length.
     | {{tl|str ≥ len}}    | To check if a string is "longer or equally long" or "shorter" than a given length.
     | {{tl|str ≤ len}}    | Check if a string is "shorter or equally long" or "longer" than a given length.
     | {{tl|str ≤ len}}    | To check if a string is "shorter or equally long" or "longer" than a given length.
     | {{tl|str ≠ len}}    | Check if a string is "not equal" or "equal" to a given length.
     | {{tl|str ≠ len}}    | To check if a string is "not equal" or "equal" to a given length.
    | {{tl|str ≤ ≥ len}}  | To check if a string is "shorter", "equal", or "longer" than a given length.
  }} }}
  }} }}


<!----------------- Analysis, technical ------------------->
<!----------------- Analysis, technical ------------------->
| abbr3 = anlys/tech
| abbr5 = anlys/tech
| sect3 = Analysis and technical
| sect5 = Analysis and searching
| content3 =
| 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:2.5em;
     {{Aligned table |style=padding-right:2em;
     |col1style=text-align:right;white-space:nowrap;padding-right:0.75em; |col2style=font-style:italic;
     |col1style=text-align:right;padding-right:0.75em;
     | {{tl|str endswith}}  | To check if a string 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}}<br/>{{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|str find0}}    | Zero-based substring search.
     | {{tl|in string}}    | Returns optional string when given string is not found
    | {{tl|str sub find}}  | Searches a substring in a string at the given offset.
     | {{tl|str count}}     | Count the number of occurrences of a pattern within a string.
     | {{tl|str letter}}   | Returns the number of letters that begin a string.
    | {{tl|str number}}    | Returns the number of numbers that begin a string.
    | {{tl|str gtr str}}  | Compares two strings for alphabetical order, and returns a value accordingly.
     }}
     }}
   |  <!---(Analysis cont'd)--->
   |  <!---(Analysis cont'd)--->
     {{Aligned table
     {{Aligned table
     |col1style=text-align:right;white-space:nowrap;padding-right:0.75em; |col2style=font-style:italic;
     |col1style=text-align:right;padding-right:0.75em;
    | {{tl|ASCII code}}    | Returns the ASCII value of a single character.
     | {{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.
     | &nbsp; | &nbsp;
     | {{tl|Array}}        | Array manipulation and retrieval.
    <!---(Technical)--->
     | {{tl|Font style}}   | Returns bold or italic if the input value has either formatting.
    | [[Module:String]]    |  
     | {{tl|Isnumeric}}     | Returns number when true, blank when not numeric.
     | [[mw:Help:Magic words|...Magic words]] | {{noitalic|About <code><nowiki>{{padleft:&#124;}}</nowiki></code>.}}
    | {{tl|str letter}}   | Returns the number of letters that begin a string.
     | [[mw:Help:Extension:ParserFunctions|...ParserFunctions]] | {{noitalic|About <code><nowiki>{{#titleparts:&#124;}}, {{#expr:&#124;}}, {{#ifeq:&#124;}}, </nowiki></code> etc.}}
    | {{tl|str number}}   | Returns the number of numbers that begin a string.
  }} }}
  }} }}
 
|state1=<noinclude>expanded</noinclude><!-- show everything on this template's page -->
<!--------------------- (disabled) ------------------------>
|state2=<noinclude>expanded</noinclude>
<!----
|state3=<noinclude>expanded</noinclude>
| group12 = Feature requests
|state4=<noinclude>expanded</noinclude>
| list12 =
|state5=<noinclude>expanded</noinclude>
* [[bugzilla:6455]] – Set $wgPFEnableStringFunctions = true on WMF wikis
|state6=expanded
* [[bugzilla:26092]] – Enable or install string parsing wikimarkup functionality on WMF wikis
|group6=Modules and built-in functions
 
|list6={{div col|style=text-align:left}}
<!----Not in a navbox:
* [[:Module:String]], [[:Module:String2]], [[:Module:Ustring]], [[Module:Text]]: modules that together contain most necessary string functions.
| group13 = [[Wikipedia:Template sandbox and test cases|Sandboxes, testcases]]
* [[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.
| list13 =
* [[mw:Help:Extension:ParserFunctions|ParserFunctions]]: About <code><nowiki>{{#titleparts:&#124;}}, {{#expr:&#124;}}, {{#ifeq:&#124;}}, </nowiki></code> etc.{{div col end}}
* {{tl|Str find/sandbox}}
* {{tl|Str index/getchar/sandbox}}
* {{tl|Str index/getchar/testcases}}
* {{tl|Str index/sandbox}}
* {{tl|Str index/testcases}}
* {{tl|Str index any/sandbox}}
* {{tl|Str index any/testcases}}
* {{tl|Str left/sandbox}}
* {{tl|Str len/core/sandbox}}
* {{tl|Str len/sandbox}}
* {{tl|Str len/testcases}}
* {{tl|Str rightc/testcases}}
* {{tl|Str ≠ len/sandbox}}
* {{tl|Str ≠ len/testcases}}
----->
 
<!----------------------- below --------------------------->
<!----------------------- below --------------------------->
| belowclass = hlist
| belowclass = hlist
| below =
| below =
* [[:Category:String manipulation templates]]
* [[:Category:String manipulation templates]]  
* [[m:Category:String templates]]
** [[:c:Category:String manipulation templates|Commons]]
* [[:commons:Category:String manipulation templates]]
** [[:mw:Category:String manipulation templates|MediaWiki]]
 
** [[:m:Category:String manipulation templates|Meta-Wiki]]
** [[:d:Category:String manipulation templates|Wikidata]]
* [[:Category:Modules that manipulate strings|Category:String manipulating modules]]
| 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 03:32, 1 June 2022