String manipulation routines
List of Global Functions
CAlnum -
CAlpha -
CDigit -
CGraph -
CLower -
CPrint -
CPunct -
CSpace -
CUpper -
CXdigit -
CutBlanks - Remove blanks at begin and end of input string.
CutRegexMatch - Remove first or every match of given regular expression from a string
CutZeros - Remove any leading zeros
EscapeTags - Function for escaping (replacing) (HTML|XML...) tags with their (HTML|XML...) meaning.
FirstChunk - Shorthand for select (splitstring (s, separators), 0, "") Useful now that the above produces a deprecation warning.
FormatSize - Return a pretty description of a byte count
FormatSizeWithPrecision - Return a pretty description of a byte count
GetCommentLines - Get comment without metadata
GetMetaDataLines - Get metadata lines from input string
NonEmpty -
OptFormat - Optional formatted text
OptParens - Optional parenthesized text
Pad - Add spaces after the text to make it long enough
PadZeros - Add zeros before the text to make it long enough.
ParseOptions - Parse string of values
ParseSysconfigComment - Parse metadata from a sysconfig comment
Quote - Quote a string with 's
Random - Make a random base-36 number. srandom should be called beforehand.
Replace - Replace substring in a string. All substrings source are replaced by string target.
TextTable - Function creates text table without using HTML tags. (Useful for commandline) Undefined option uses the default one.
UnQuote - Unquote a string with 's (quoted with quote)
UnderlinedHeader - Function returns underlined text header without using HTML tags. (Useful for commandline)
ValidCharsFilename - Characters valid in a filename (not pathname). Naturally "/" is disallowed. Otherwise, the graphical ASCII characters are allowed.
WrapAt - Returns text wrapped at defined margin. Very useful for translated strings used for pop-up windows or dialogs where you can't know the width. It controls the maximum width of the string so the text should allways fit into the minimal ncurses window. If you expect some long words, such us URLs or words with a hyphen inside, you can also set the additional split-characters to "/-". Then the function can wrap the word also after these characters. This function description was wrapped using the function String::WrapAt().
List of Global Variables
Remove blanks at begin and end of input string.
Function parameters
string input
Return value
string - stripped string
Remove first or every match of given regular expression from a string
Function parameters
string input
string regex
boolean glob
Return value
string - that has matches removed
Remove any leading zeros
Function parameters
string input
Return value
string - that has leading zeros removed
Function for escaping (replacing) (HTML|XML...) tags with their (HTML|XML...) meaning.
Function parameters
string text
Return value
string - escaped text
Shorthand for select (splitstring (s, separators), 0, "") Useful now that the above produces a deprecation warning.
Function parameters
string s
string separators
Return value
string - first component or ""
Return a pretty description of a byte count
Function parameters
integer bytes
Return value
string - formatted string
Return a pretty description of a byte count
Function parameters
integer bytes
integer precision
boolean omit_zeroes
Return value
string - formatted string
Example 65.
FormatSizeWithPrecision(4096, 2, true) -> "4 KB" FormatSizeWithPrecision(4096, 2, false) -> "4.00 KB"
Get comment without metadata
Function parameters
string input
Return value
string - Comment used as variable description
Get metadata lines from input string
Function parameters
string input
Return value
list<string> - Metadata lines in list
Function parameters
string s
Return value
list<string> - the items as a list, with empty lines removed
Optional formatted text
Function parameters
string f
string s
Return value
string - sformat (f, s) if s is neither empty or nil, else ""
Optional parenthesized text
Function parameters
string s
Return value
string - " (Foo)" if Foo is neither empty or nil, else ""
Add spaces after the text to make it long enough
Function parameters
string text
integer length
Return value
string - padded text
Add zeros before the text to make it long enough.
Function parameters
string text
integer length
Return value
string - padded text
Parse string of values
Function parameters
string options
map parameters
Return value
list<string> - List of strings
Parse metadata from a sysconfig comment
Function parameters
string comment
Return value
map<string, string> - parsed metadata
Quote a string with 's
Function parameters
string var
Return value
string - quoted string
Make a random base-36 number. srandom should be called beforehand.
Function parameters
integer len
Return value
string - random string of 0-9 and a-z
Replace substring in a string. All substrings source are replaced by string target.
Function parameters
string s
string source
string target
Return value
string - result
Function creates text table without using HTML tags. (Useful for commandline) Undefined option uses the default one.
Function parameters
list<string> header
list <list <string> > items
map <string, any> options
Return value
string - table Header: [ "Id", "Configuration", "Device" ] Items: [ [ "1", "aaa", "Samsung Calex" ], [ "2", "bbb", "Trivial Trinitron" ] ] Possible Options: horizontal_padding (for columns), table_left_padding (for table)
Unquote a string with 's (quoted with quote)
Function parameters
string var
Return value
string - unquoted string
Function returns underlined text header without using HTML tags. (Useful for commandline)
Function parameters
string header_line
integer left_padding
Return value
string - underlined header line
Characters valid in a filename (not pathname). Naturally "/" is disallowed. Otherwise, the graphical ASCII characters are allowed.
Return value
string - for ValidChars
Returns text wrapped at defined margin. Very useful for translated strings used for pop-up windows or dialogs where you can't know the width. It controls the maximum width of the string so the text should allways fit into the minimal ncurses window. If you expect some long words, such us URLs or words with a hyphen inside, you can also set the additional split-characters to "/-". Then the function can wrap the word also after these characters. This function description was wrapped using the function String::WrapAt().
Function parameters
string text
integer width
string split_string
Return value
string - wrapped string