Utf8.insert
Jump to navigation
Jump to search
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. For more information on optional arguments, see optional arguments.
- insert_pos: An integer representing the position, where the substring will be inserted at.
Returns
Returns a string with the inserted substring value.
Example
Click to collapse [-]
ServerThis example shows a command handler for '/insert [something]', which will concatenate the '[something]' after the 'hello ' string in 2 ways.
addCommandHandler("insert", function (player, command, word) if word then local output = utf8.insert( "hello ", word ) outputChatBox( output, player ) local output = utf8.insert( "hello ", utf8.len( "hello " ) + 1, word ) outputChatBox( output, player ) end end )
See Also
- utf8.byte
- utf8.char
- utf8.charpos
- utf8.escape
- utf8.find
- utf8.fold
- utf8.gmatch
- utf8.gsub
- utf8.insert
- utf8.len
- utf8.lower
- utf8.match
- utf8.ncasecmp
- utf8.next
- utf8.remove
- utf8.reverse
- utf8.sub
- utf8.title
- utf8.upper
- utf8.width
- utf8.widthindex