Utf8.remove

From Multi Theft Auto: Wiki
Revision as of 05:11, 2 July 2016 by Lexr128 (talk | contribs) (→‎Example)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This function removes a substring in a UTF-8 string by using a position range.

Syntax

string utf8.remove ( string input, int start = 1 [, int stop = -1 ] )

Required Arguments

  • input: A string character sequence
  • start: An integer representing the beginning position.

Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.

  • stop: An integer representing the ending position.

Returns

Returns the string with the removed substring from the range.

Example

Click to collapse [-]
Server

This example shows how to remove substrings from strings.

-- Keep the first and last character
local input = "яблоко"
local output = utf8.remove( input, 2, -2 ) 
print( output ) -- яо

-- Remove the last character
local input = "Банан"
local output = utf8.remove( input, -1, -1 )
print( output ) -- Бана

See Also