What is str and f? You seem to be combining str with f but you haven’t defined either of them. Also, gsub only returns 1 item so why do you have i as a second variable?
Can you provide the declarations for str, f, and i? I set up the same code and it worked for me, so perhaps your declarations for each variable are what is causing the problem.
When i used studio var incpector, it showed this
str=function () {
something
}
digitalWrite(50,true)
function () {
something
}function () {
something
}
(the last one function () {something} was added by the line that is adding f)
f=f function () {
something
}
i=nil
and after it
everything is same, but
i=0
I have no idea what that is, and I am somewhat confused on how to read it. I was not asking for whatever that is, I am asking for how you defined the variables str, j, and i.
And i tried to change f to “i”, and it worked, so here must be the problem.
Edit #1: And i tried string.gsub(f,f,“”), but also didnt work. So the problem can be, that the string includes ().
Edit #2: I tried to remove () and it works. So how to make gsub ignoring it?
Above shows you that it’s a magic character with code: this shows you that it’s a magic character with documentation. Just thought to tack that on.
Did you use them in a position where they couldn’t be a quantifier?
print(string.match("a","+")) --> nil
print(string.match("a","a+")) --> a
A similar thing happens with the anchors ^ and $, when ^ isn’t the first character, it matches a ^, and when $ isn’t the last character, it matches a $. When one of the quantifiers (*,+,-,?) is used outside of a position where it would be interpreted as a quantifier, it’s treated like a non magic character, so it matches it.