string.gsub not working
Opened this issue · 1 comments
Z6P0 commented
For example:
string.gsub("test","t","T")
returns"test"
string.gsub("test","t","T",1)
returns"st"
chenasraf commented
Can confirm still happens.
The code used to generate this is very basic:
final code = '''
local cmd = "this is a test!"
cmd = string.gsub(cmd, "is", "IS")
Send(cmd)
''';
LuaState state = LuaState.newState();
state.openLibs();
state.pushDartFunction(send);
state.setGlobal("Send");
state.loadString(code);
state.call(0, 0);
// elsewhere
int send(LuaState ls) {
final cmd = ls.checkString(1) ?? '';
ls.pop(1);
debugPrint("lua.Send $cmd");
store.send(cmd);
return 0;
}
Here is my output:
ActionSendTo.script:
local cmd = "this is a test!"
cmd = string.gsub(cmd, "is", "IS")
Send(cmd)
lua.Send this is a test!
The last line should be "this IS a test!"