• Question with string.find
    2 replies, posted
I'm using string.find to find operators in a string, here is what I have: [lua]errlist = {"/+", "//", "/-", "/*", "*/", "*-", "**", "*+", "-*", "-/", "+*", "+/"} function errorcheck(str) for k, v in pairs(errlist) do if(string.find(str, v)) then string = "ERROR" end end end [/lua] But when I only put in a + or - and no other operator, it still changes the text to ERROR, which is not what I want, I only want the ones in the table to be changed to error. One guess is that the * are acting as wildcards and I don't know how to make it where that won't happen anymore, because I don't want it to. Any clues on how to fix this?
string.find(str, v, 1, true) to not use regular expressions.
Thanks JetBoom that worked.
Sorry, you need to Log In to post a reply to this thread.