string.gsub

From ComputerCraft
Jump to: navigation, search

string.gsub
Function
Syntax
string.gsub()
Colon notation: sentence:gsub()

Returns string
API string
Source Lua (source)

Replaces a string in a sentence.

ExampleExampleReplace all letter "l"
All letters "l" have been replaced by the letter "L".
Code
string.gsub("hello world","l","L")
Output heLLo worLd
ExampleExampleLimit the substitutions
It limits the substitutions to the first 2 letters found
Code
string.gsub("hello world","l","L",2)
Output heLLo world