Utf8.remove: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (tweaks)
 
Line 30: Line 30:
local input = "Банан"
local input = "Банан"
local output = utf8.remove( input, -1, -1 )
local output = utf8.remove( input, -1, -1 )
print( output )
print( output ) -- Бана
</syntaxhighlight>
</syntaxhighlight>
</section>
</section>

Latest revision as of 05:11, 2 July 2016

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