Birk
Birk

Reputation: 211

Lua: Remove a character from string

How would i for an example remove the h from "helloh" so it will look like "ello"


I have no idea what else to write but it looks like i need to write some more text and maybe add some code so this is just junk.

print("junk 1")
print("junk 2")
print("junk 4")

Upvotes: 3

Views: 9771

Answers (1)

Nifim
Nifim

Reputation: 5021

You can used string.gsub to replace characters, gsub stands for global subtitusion.

print(("helloh"):gsub("h", "")) -- replace all instances of `h` with empty string 

Upvotes: 4

Related Questions