3

I'm new to Lua and I'm sure this is a silly problem.

I was trying to remove first 3 characters from a string with string.gsub Here is the code:

string.gsub(m, "/jk", "", 1)

Now "/jk" are the first 3 chars the string, now, string.gsub adds a space instead of removing them. My question is, how to remove them without adding the space?

John Smith
  • 12,491
  • 18
  • 65
  • 111
nuberelo
  • 57
  • 1
  • 2
  • 5

1 Answers1

8

string.gsub doesn't add a space unless you ask it to, and in your pasted code you aren't asking it to. Are you sure there wasn't already a space after the /jk in the string?

Also, if you're just trying to remove the first 3 characters, you should use string.sub(m, 4).

Lily Ballard
  • 182,031
  • 33
  • 381
  • 347