Template:String-handling templates: Difference between revisions

From Zoophilia Wiki
Jump to navigationJump to search
meta>DePiep
/doc
meta>DePiep
turn into navbox
Line 1: Line 1:
<noinclude><big>List of templates in {{cat|String manipulation templates}}.</big>
{{navbox
</noinclude>==Templates==
| title= String handling templates
===[[Trim (programming)|Trimming]] strings by counting===
| name=String templates see also text/sandbox
* {{tl|Str mid}} &mdash; To return a substring, specified by its position and length.
| state={{{state}|}}}
 
| above=''As of February 2013, these templates are being optimised using [[WP:Lua|Lua]] modules. More [[Template:String templates see also text|here]].''
| group1 = [[Trim (programming)|Trim]] by counting
| list1=
* {{tl|Str mid}} To return a substring, specified by its position and length.
* {{tl|Trunc}} – To trim down to a specified number of characters.
* {{tl|Trunc}} – To trim down to a specified number of characters.
* {{tl|Str left}} – To trim down to a specified number of characters, or duplicate the string to a specified number.
* {{tl|Str left}} – To trim down to a specified number of characters, or duplicate the string to a specified number.
* {{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.
* {{tl|Str right}} To trim the first specified number of characters.
* {{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.
* {{tl|Str sub old}} To trim down to a specified number, starting at a given number from the left.
* {{tl|Str sub old}} To trim down to a specified number, starting at a given number from the left.
* {{tl|Str sub new}} Select a substr based on starting and ending index.
* {{tl|Str sub new}} Select a substr based on starting and ending index.
* {{tl|Str index}} – Returns a given character from a string, but not accented letters.


===Trimming strings by character checking===
| group2=Trim by checking
* {{tl|Trim}} To trim any leading or trailing whitespace ({{tl|Strip whitespace}} does so too, but is less effective)
| list2=
* {{tl|First word}} To trim down to the first space.
* {{tl|Trim}} To trim any leading or trailing whitespace ({{tl|Strip whitespace}} does so too, but is less effective)
* {{tl|Remove first word}} To remove anything before the first space.
* {{tl|First word}} To trim down to the first space.
* {{tl|Str letter/trim}} To trim down to the beginning letters.
* {{tl|Remove first word}} To remove anything before the first space.
* {{tl|Str number/trim}} To trim down to the beginning numbers.
* {{tl|Str letter/trim}} To trim down to the beginning letters.
* {{tl|Title without disambig}} — To trim off any parenthesis text at the end of a string.
* {{tl|Str number/trim}} To trim down to the beginning numbers.
* {{tl|Title disambig text}} – Returns text in parenthesis at the end of a string.


===Inserting strings===
| group3= Insert strings
|list3=
* {{tl|Repeat}} – Repeat character string n times
* {{tl|Replace}} – Returns the string, after replacing ''all'' occurrences of a specified string with another string.
* {{tl|Strloc insert}} – Inserts a string at character location strloc, or appends if strloc<=0.
* {{tl|Strloc prefix}} – Extracts string prefix up to location strloc, or whole string if strloc<=0.
* {{tl|Str rep|Str rep}} – Returns the string, after replacing the first occurrence of a specified string with another string.


* {{[[Template:Strloc insert|Strloc insert]]}} - Inserts a string at character location strloc, or appends if strloc<=0.
|group4= Length
* {{[[Template:Strloc prefix|Strloc prefix]]}} - Extracts string prefix up to location strloc, or whole string if strloc<=0.
|list4=
* {{[[Template:Str rep|Str rep]]}} — Returns the string, after replacing the first occurrence of a specified string with another string.
* {{tl|Str len}} – Returns a string's length.
* {{tl|Replace}} — Returns the string, after replacing ''all'' occurrences of a specified string with another string.
* {{tl|iflenge}} – IF LENgth Greater then or Equal to.
* {{[[Template:Repeat|Repeat]]}} — Repeat character string n times
* {{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 "shorter or equally long" or "longer" than a given length.
===Analyzing strings templates===
* {{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.


| group5=Analyse string
| list5=
* {{tl|Str endswith}} – To check if a string ends with a given string.
* {{tl|Str endswith}} – To check if a string ends with a given string.
* {{tl|Str find}} – Returns the numerical location of a given string in a string.
* {{tl|Str find}} – Returns the numerical location of a given string in a string.
* {{tl|Strfind short}} – Returns the numerical location of a given string in a string. 1-based
* {{tl|Strfind short}} – Returns the numerical location of a given string in a string.
* {{tl|Str find0}} – Zero-based substring search.
* {{tl|Str find0}} – Zero-based substring search.
* {{tl|Str sub find}} – Searches a substring in a string at the given offset.
* {{tl|Str sub find}} – Searches a substring in a string at the given offset.
* {{tl|Str index}} – Returns a given character from a string, but not accented letters.
* {{tl|ASCII code}} – Returns the ASCII value of a single character.
* {{tl|Str len}} – Returns a string's length.
* {{tl|Str letter}} – Returns the number of letters that begin 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 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.
* {{tl|Ship prefix}} — Returns the length of a ship name prefix, if listed.


===String length comparison templates===
| group6=Trim, dedicated
| list6=
* {{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 name prefix, if listed (ship names).
* {{tl|Title without disambig}} – 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|Unlink}} – Removes wikilink brackets (wikicode).


* {{tl|Str ≥ len}} – To check if a string is "longer or equally long" or "shorter" than a given length.
|group11=Technical developments
* {{tl|Str ≤ len}} – To check if a string is "shorter or equally long" or "longer" than a given length.
|list11=
* {{tl|Str ≠ len}} – To check if a string is "not equal" or "equal" to a given length.
* [[Module:String]]
* {{tl|Str ≤ ≥ len}} – To check if a string is "shorter", "equal", or "longer" than a given length.
* [[mw:Help:Magic words]] – About <code><nowiki>{{padleft:|}}</nowiki></code>.
* [[mw:Help:Extension:ParserFunctions]] – About <code><nowiki>{{#titleparts:|}}, {{#expr:|}}, {{#ifeq:|}}, </nowiki></code> etc.
 
|group12=Feature requests
|list12
* [[bugzilla:6455]] Set $wgPFEnableStringFunctions = true on WMF wikis
* [[bugzilla:26092]] – Enable or install string parsing wikimarkup functionality on WMF wikis


==Test cases==
<!-- not in a navbox
[[Wikipedia:Template sandbox and test cases|Sandboxes and test cases]]:
|group13=[[Wikipedia:Template sandbox and test cases|Sandboxes and test cases]]:
|list13=


* {{tl|Str find/sandbox}}
* {{tl|Str find/sandbox}}
Line 67: Line 94:
* {{tl|Str ≠ len/sandbox}}
* {{tl|Str ≠ len/sandbox}}
* {{tl|Str ≠ len/testcases}}
* {{tl|Str ≠ len/testcases}}
-->
| below=
* [[:Category:String manipulation templates]]
* [[m:Category:String templates]]
* [[:commons:Category:String manipulation templates]]
| belowclass=hlist
}}<noinclude>


==Technical developments==
* [[Module:String]]
* [[mw:Help:Magic words]] – About <code><nowiki>{{padleft:|}}</nowiki></code>.
* [[mw:Help:Extension:ParserFunctions]] – About <code><nowiki>{{#titleparts:|}}, {{#expr:|}}, {{#ifeq:|}}, </nowiki></code> etc.
;Feature requests:
* [[bugzilla:6455]] - Set $wgPFEnableStringFunctions = true on WMF wikis
* [[bugzilla:26092]] - Enable or install string parsing wikimarkup functionality on WMF wikis
<noinclude>
{{documentation}}
{{documentation}}
</noinclude>
</noinclude>

Revision as of 11:50, 27 February 2013