utf8.insert | Multi Theft Auto: Wiki Skip to content

utf8.insert

Client-side
Server-side
Shared

Inserts a substring into input string. If insert-position is given, the substring will be inserted before the character at this index, otherwise the substring will concatenate to input. The insert position may be negative.

Syntax

string utf8.insert ( string input, [ int insert_pos = utf8.len( input ) + 1 ], string substring )
Required Arguments
  • input: A string character sequence.
  • substring: A string character sequence which should be inserted.
Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use.

  • insert_pos (default: utf8.len( input ) + 1): An integer representing the position, where the substring will be inserted at.

Returns

  • string: value

Returns a string with the inserted substring value.

Code Examples

shared

This example will concatenate the '[something]' after the 'hello ' string in 2 ways.

local word = 'world'
local output = utf8.insert('hello ', word)
print(output) -- hello world
local output2 = utf8.insert('hello ', utf8.len('hello ') + 1, word)
print(output2) -- hello world