Вопрос

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?

Это было полезно?

Решение

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).

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top