Cannot find character "^" with string.find

I need some help because this bug is driving me completely insane.

I’ve narrowed down the exact issue with my code to this line:

local cst,cen = string.find(newstr,"^")

I know through prints that newstr is : 1={LF=-f0.313,5.048,0.513:-0.825,0.343,0.45^

However, no matter what I pass as newstr, cst will always equal 1 and cen will always be 0. Does anyone know why this is?

String.find should take the string variable.

Str = “Hello world”

If Str.find(“Hello”) == true then

End

That’s not the issue. I’ve already found the issue. It’s because you can’t use special characters directly in string.find.

For future reference if anyone else has this issue, you can’t call string.find on the following characters:

$ % ^ * ( ) . [ ] + - ?

1 Like

I’m not at a pc to check, but look into string.format then, so you can use special chars

You actually can use string.find to find those characters, but you need to escape them with a % before it, so to find the ^ character in your example it would be:

local cst,cen = string.find(newstr,"%^")

1 Like

^^ exactly.
Here is the api, that I was referring too.

Be sure mark a solution, and confirm that it’s not a bug.