warframe

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:

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:
  • str A string (string)
  • search The element that is being searched for (string)
  • ignoreCase If 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:
  • str Input string (string)
  • sep A 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:
  • str String to be checked (string)
  • start Potential starting substring of str (string)
  • ignoreCase If 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: str Input 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: str Input string (string)
Returns: Trimmed resultant string in title casing format (string)
string.newLinesToBreaks(str) (function)
Converts newlines to HTML line breaks.
Parameter: str Input 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: str Input 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: x Input 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: x Input 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: x Input string (string)
Returns: The binary representation of string (string)

Created with Docbunto

See Also


Code