Module:String/doc

This module Houses general purpose string functions for ease of use in other modules.

Loading the module
To load this module, Add this line of code to the start of your module:

All methods described below will be available under the loaded table.

Methods
All methods are available below as fields under the required object name.
 * NOTE&#58; All functions described here are NOT part of the original lua string library. they are stored under this object for simplicity.

string.ucfirst
This method returns with the first letter of every word to upper case.

string.lcfirst
This method works exactly like, but with every letter of the first word being uppercase.

string.blankCell
This method returns a HTML blank cell like blank cell.

string.infoNeeded
This method returns a info needed text like InfoNeeded.

string.reverseSymbol
This method returns a copy of with certain characters like [ or {{code|{}}  replaced with their flipped counterparts. It also reverses the returned string with if the parameter  is set to true.

string.pcall
This method calls with the arguments as set in. If no error is raised in calling the function, all values returned by are returned. Else, it returns the error message as a template error.

string.makeTitle
This method returns a HTML &lt;abbr> element ( if is set to true) with the title attribute set to the text of  and the inner text as. If is set to true,  is not required (otherwise required).

string.parseDualArg
This method returns the value if it is a string, if it is a table, it concatenates it with with an empty string as a default parameter or the sep field in the provided table, if it is a number, it converts it to a string.

string.wrapLink
This method returns a wikilink with as the link target, and  as the display text.

string.externalUrl
This method returns an external link to a external website provided by with  as an optional URL query and optional alternate text provided by.

string.fullUrl
This method returns an internal URL to a page provided by with  as an optional URL query and optional alternate text provided by  in a similar fashion to.

string._repeat
This method takes the string in and repeats it according to the delimiter  separated by the text specified in  if it is omitted.

string.wrapHtml
Alternative Calls: This method is provided as a light-weight alternative to. If you need to make more complex elements like tables, use. The function returns wrapped by the html element with the tag name specified in  with the attributes in  if the parameter is omitted.

There are special cases for attributes:
 * Class: - The class names for the element can be just a string, or it can be an table of classes. If the input is a table, the keys in the arrays are joined by spaces.
 * Style: - The css rule can be just a string, or it can be a table. In the case of the attribute being a table, the attribute is a CSS rule with the table key as the CSS property name, and the value as the CSS value of the omitted property.

Examples

 * Regular example

Produces: Foo
 * Table function call

Produces: Foo
 * Special Attribute values

Produces: Foo

string._formatShortNum
This method returns a short formatted version of like 10k.

string._toNumber
This method converts a string (can be a formatted number returned by the method above) to a number using.

string._formatNum
This method converts to a formatted number using.

string.error
This method returns a string as a template error with and  as arguments to

string.centerText
This method returns a &lt;div> element that aligns the text to the center of an element using.

string._toRoman
This method returns a copy of with numbers converted to roman numerals.

string._toArabic
This method returns a copy of with roman numerals converted to numbers. Basically it is a oposite of.

string._splitNameAndTier
This method extracts a name and tier from the target string. It returns a table with 2 values, the first being the name, the second being the tier.

string._lorem
This method returns a lorem sample text based on the length of.

string.roundNumber
This method returns rounded to the number of decimal places specified by. defaults to 1.

string._delDoubleSpace
This method returns a copy of with all duplicate spaces removed using the following lua pattern: (%s)%s* with the replacement being %1.