User:VasilievVV/Lua strings

From mediawiki.org

Members of unicode module (all return false if a string is invalid UTF-8 sequence):

  • unicode.len(string) — returns length or false if it is invalid UTF-8 sequence
  • unicode.pos(haystack, needle, offset) — returns position of needle in haystack, starting search with offset. Returns offset of the substring, -1 if it is not found.
  • unicode.at(string, pos) — returns the character at the position pos
  • unicode.sub(string, start, len) — returns the string from start at most start + len.
  • unicode.uc(string) — converts all letters in the string to uppercase.
  • unicode.ucfirst(string) — converts the first symbol of the string to uppercase, if it is a letter.
  • unicode.lc(string) — converts all the symbols in the string to lowercase
  • unicode.replace(string, from, to) — replaces all the occurrences of from to to in string.
  • unicode.trim(string) — removes all whitespace from the beginning and the end of the string and returns the result
  • unicode.code(string) — returns the Unicode code of the first character of the string
  • unicode.split(string, delimiter) — splits the string into an array of items which were separated in the original by delimiter
  • unicode.join(table, delimiter) — joins the table elements, using delimiter as a glue between table items