This is the documentation page for Module:String
String is an extension of the string STL which provides operations on string values.
String can be invoked directly ({{#invoke:String|function|...}}), invoked from a template ({{template|function|...}}), or used within other modules.
For additional functions that operate on strings, you can look into the mw.ustring and mw.text libraries that comes with Scribunto:
- https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Ustring_library
- https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Text_library
On this Wiki, String is used in:
Usage
Module
local p = {}
local String = require('Module:String')
local function func(input)
-- ...
-- input -> stuff
-- ...
return String.titleCase(stuff)
end
Documentation
Package items
string.contains(str, search, ignoreCase)(function)- Performs a case-sensitive check if a string is a substring of a string.
- Parameters:
strA string (string)searchThe element that is being searched for (string)ignoreCaseIf false, search is case-sensitive; true otherwise; defaults to false (boolean; optional)
- Returns: True if element exists in List, false otherwise (boolean)
string.split(str, sep)(function)- Splits a string into substrings based on a separating character. For example, split('Lith V1 Relic', '%s') would return { 'Lith', 'V1', 'Relic' }
- Parameters:
strInput string (string)sepA string separator using Lua's character sequences; default '%s', note that separator will be trimmed of whitespace (string; optional)
- Returns: A table with substrings of inputstr (table)
string.startsWith(str, start, ignoreCase)(function)- Checks if a string begins with a certain substring. For example calling startsWith ("Lith V1 Relic", "Lith") would return true.
- Parameters:
strString to be checked (string)startPotential starting substring of str (string)ignoreCaseIf false, search is case-sensitive; true otherwise; defaults to false (boolean)
- Returns: True if a string begins with start, false otherwise (boolean)
string.trim(str)(function)- Trims leading and trailing whitespace of a string. Source: http://lua-users.org/wiki/StringTrim
- Parameter:
strInput string (string) - Returns: Trimed string (string)
string.titleCase(str)(function)- Returns a string in title casing format. Originally from Module:VoidByReward written by User:NoBrainz. Reworked on 11/9/2020 by User:Gigamicro.
- Parameter:
strInput string (string) - Returns: Trimmed resultant string in title casing format (string)
string.newLinesToBreaks(str)(function)- Converts newlines to HTML line breaks.
- Parameter:
strInput string (string) - Returns: A string that has its carriage returns and newlines replaced with break tag (string)
string.UNPRINTABLE_CHARACTER_MAP(table)- Mapping unprintable characters (1 byte) to printable ones (2 bytes). Mapping control characters U+0000 to U+001F with Cyrillic characters U+0400 to U+041F. Mapping U+007F to U+00FF with Cyrillic characters U+0420 to U+0482 and U+048A to U+04A7 (skipping accent marks) Any characters between \127 and \255 inclusive are not printable to debug console for some reason which is why this map is needed.
string.escape(str)(function)- Escapes any unprintable characters to its Lua 3-digit encoding equivalent (e. g. embedded zeroes are "\000")
- Parameter:
strInput string (string) - Returns: A string with unprintable characters escaped (string)
string.hexquad(table)- Mapping hex chars to equivalent 4b binary strings octal is a little slower but cuts this table, just use ('%O'):format()
string.integerToBinary(x)(function)- Returns the binary representation of an unsigned integer, ignoring any decimal places (no padded zeros and in big-endian).
- Parameter:
xInput number (string|number) - Returns: The binary representation of unsigned integer (string)
string.charToBinary(x)(function)- Returns the binary representation of a character (no padded zeros and in big-endian).
- Parameter:
xInput string (string) - Returns: The binary representation of character (string)
string.stringToBinary(x)(function)- Returns the binary representation of a string (with padded zeroes and in big-endian) with each character separated by a space.
- Parameter:
xInput string (string) - Returns: The binary representation of string (string)
- Created with Docbunto
See Also