Garry's Mod Wiki

string.SetChar

  string string.SetChar( string InputString, number Index, string ReplacementChar )

Description

Sets the character at the specific index of the string.

Arguments

1 string InputString
The input string
2 number Index
The character index, 1 is the first from left.
3 string ReplacementChar
String to replace with.

Returns

1 string
ModifiedString

Example

Demonstrates the use of SetChar

local str = "Apples" MsgN(string.SetChar(str, 3, "g"))
Output: "Apgles"