Utf8.remove

From Multi Theft Auto: Wiki
Revision as of 16:14, 15 February 2016 by Necktrox (talk | contribs) (Created page with "__NOTOC__ {{Shared function}} This function removes a substring in a UTF-8 string by using a position range. ==Syntax== <syntaxhighlight lang="lua">string utf8.remove ( string input, int sta...")
(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: A number 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: A number 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