Difference between revisions of "Template:String-handling templates"
From Ava Zinn Wiki
[unchecked revision] | [unchecked revision] |
m (link update) |
Aeverinezinn (talk | contribs) m (86 revisions from wikipedia:Template:String-handling templates) |
||
(14 intermediate revisions by 7 users not shown) | |||
Line 1: | Line 1: | ||
− | {{Navbox with collapsible | + | {{Navbox with collapsible groups |
| name = String-handling templates | | name = String-handling templates | ||
| state = {{{state|expanded}}} | | state = {{{state|expanded}}} | ||
Line 22: | Line 22: | ||
| {{tl|str crop}} | To crop a specified number of characters off the end. | | {{tl|str crop}} | To crop a specified number of characters off the end. | ||
| {{tl|chop head and tail}} | To crop a specified number of characters off the beginning and end. | | {{tl|chop head and tail}} | To crop a specified number of characters off the beginning and end. | ||
− | |||
}} | }} | ||
| {{Aligned table | | {{Aligned table | ||
|col1style=width:12.5em;text-align:right;white-space:nowrap;padding-right:0.75em; |col2style=font-style:italic; | |col1style=width:12.5em;text-align:right;white-space:nowrap;padding-right:0.75em; |col2style=font-style:italic; | ||
+ | | {{tl|str right}} | To trim the first specified number of characters. | ||
| {{tl|str rightc}} | To return a number of characters from the end, returns a parameter if the string is empty. | | {{tl|str rightc}} | To return a number of characters from the end, returns a parameter if the string is empty. | ||
| {{tl|str rightmost}} | To trim down to the last specified number of characters. | | {{tl|str rightmost}} | To trim down to the last specified number of characters. | ||
Line 39: | Line 39: | ||
|col1style=width:12.5em;text-align:right;white-space:nowrap;padding-right:0.75em; |col2style=font-style:italic; | |col1style=width:12.5em;text-align:right;white-space:nowrap;padding-right:0.75em; |col2style=font-style:italic; | ||
| {{tl|trim}} | To trim any leading or trailing whitespace | | {{tl|trim}} | To trim any leading or trailing whitespace | ||
− | | {{tl| | + | | {{tl|str letter/trim}} | To trim down to the beginning letters. |
− | | {{tl| | + | | {{tl|str number/trim}} | To trim down to the beginning numbers. |
+ | | {{tl|trim brackets}} | To trim any leading or trailing square brackets. | ||
}} | }} | ||
| {{Aligned table | | {{Aligned table | ||
|col1style=width:12.5em;text-align:right;white-space:nowrap;padding-right:0.75em; |col2style=font-style:italic; | |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|remove first word}} | To remove anything before the first space. | ||
− | | {{tl| | + | | {{tl|last word}} | To trim down from the last space. |
− | | {{tl| | + | | {{tl|remove last word}} | To remove anything after the last space. |
}} }} | }} }} | ||
Line 54: | Line 56: | ||
| {{Aligned table |style=padding-right:2.5em; | | {{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; | |col1style=width:12.5em;text-align:right;white-space:nowrap;padding-right:0.75em; |col2style=font-style:italic; | ||
− | | {{tl| | + | | {{tl|delink}} | Removes wikilink brackets (wikicode). |
− | | {{tl|remove | + | | {{tl|remove file prefix}} | Removes "File:" (or "Image:") from filenames. |
− | | {{tl| | + | | {{tl|PAGENAMEBASE}} | To trim off any parenthesis text at the end of a string (disambiguation). |
| {{tl|title disambig text}} | Returns text in parenthesis at the end of a string (disambiguation). | | {{tl|title disambig text}} | Returns text in parenthesis at the end of a string (disambiguation). | ||
}} | }} | ||
| {{Aligned table | | {{Aligned table | ||
|col1style=width:12.5em;text-align:right;white-space:nowrap;padding-right:0.75em; |col2style=font-style:italic; | |col1style=width:12.5em;text-align:right;white-space:nowrap;padding-right:0.75em; |col2style=font-style:italic; | ||
− | | {{tl| | + | | {{tl|WikiProjectbasename}} | Removes "WikiProject" from a pagename. |
| {{tl|remove unranked}} | Removes the string "unranked_" from the left of a string (taxonomy). | | {{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. | ||
}} }} | }} }} | ||
}} | }} | ||
Line 76: | Line 79: | ||
|col1style=text-align:right;white-space:nowrap;padding-right:0.75em; |col2style=font-style:italic; | |col1style=text-align:right;white-space:nowrap;padding-right:0.75em; |col2style=font-style:italic; | ||
| {{tl|strloc insert}} | Inserts a string at character location strloc, or appends if strloc<{{=}}0. | | {{tl|strloc insert}} | Inserts a string at character location strloc, or appends if strloc<{{=}}0. | ||
− | | {{tl| | + | | {{tl|loop}} | Repeat character string a specified number of times. |
− | | {{tl| | + | | {{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. | ||
− | |||
}} | }} | ||
| <!---(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;white-space:nowrap;padding-right:0.75em; |col2style=font-style:italic; | ||
+ | | {{tl|str len}} | Returns a string's length. | ||
| {{tl|iflenge}} | [if len]gth [g]reater than or [e]qual to. | | {{tl|iflenge}} | [if len]gth [g]reater than or [e]qual to. | ||
| {{tl|str ≥ len}} | To 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. |
Latest revision as of 01:13, 7 March 2016
|
Template documentation[create]
Editors can experiment in this template's sandbox (create | mirror) and testcases (create) pages. Please add categories to the /doc subpage. Subpages of this template. |