Module cString

Common string-manipulation methods .

#

Functions

split (str, pat) split string - original script: http://lua-users.org/wiki/SplitJoin
trim (s) remove trailing and leading whitespace from string.
capitalize (s) capitalize first letter of every word
soft_wrap (str) insert return code whenever we encounter dashes or spaces in a string TODO keep dashes, and allow a certain length per line
detect_counter_in_str (str) detect counter in string (used for incrementing, unique names)
sanitize_string (str) prepare a string so it can be stored in XML attributes (strip illegal characters instead of trying to fix them)
get_sortable_time (tstamp) sortable time - date which can be sorted alphabetically
strip_line (str, patt) Strip line matching pattern, from multiline string
strip_leading_trailing_chars (str, chr, rlead, rtrail) Strip leading and/or trailing character from string
table_to_string (t, args) present a lua table as a formatted string


Functions

split (str, pat)
split string - original script: http://lua-users.org/wiki/SplitJoin

Parameters:

  • str (string)
  • pat (string) pattern

Returns:

    table
trim (s)
remove trailing and leading whitespace from string. http://en.wikipedia.org/wiki/Trim_(8programming)

Parameters:

  • s (string)

Returns:

    string
capitalize (s)
capitalize first letter of every word

Parameters:

  • s (string)

Returns:

    string
soft_wrap (str)
insert return code whenever we encounter dashes or spaces in a string TODO keep dashes, and allow a certain length per line

Parameters:

  • str (string)

Returns:

    string
detect_counter_in_str (str)
detect counter in string (used for incrementing, unique names)

Parameters:

  • str
sanitize_string (str)
prepare a string so it can be stored in XML attributes (strip illegal characters instead of trying to fix them)

Parameters:

  • str (string)

Returns:

    string
get_sortable_time (tstamp)
sortable time - date which can be sorted alphabetically

Parameters:

  • tstamp [[

Returns:

    string
strip_line (str, patt)
Strip line matching pattern, from multiline string

Parameters:

  • str (string)
  • patt (string)

Returns:

  1. str, resulting string
  2. int, #stripped lines
strip_leading_trailing_chars (str, chr, rlead, rtrail)
Strip leading and/or trailing character from string

Parameters:

  • str (string) the string to search
  • chr (string) the character to match, e.g. "\n" or " "
  • rlead (bool) remove leading
  • rtrail (bool) remove trailing

Returns:

    str
table_to_string (t, args)
present a lua table as a formatted string

Parameters:

  • t (table)
  • args (table) formatting directives multiline: if false, create single-line string number_format: formatting for numeric values (e.g. precision)

Returns:

    string
generated by LDoc 1.4.2