Utf8.remove: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(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...")
 
 
(One intermediate revision by one other user not shown)
Line 9: Line 9:
===Required Arguments===
===Required Arguments===
*'''input:''' A string character sequence
*'''input:''' A string character sequence
*'''start:''' A number representing the beginning position.
*'''start:''' An integer representing the beginning position.


===Optional Arguments===
===Optional Arguments===
{{OptionalArg}}
{{OptionalArg}}
*'''stop:''' A number representing the ending position.
*'''stop:''' An integer representing the ending position.


===Returns===
===Returns===
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