How to add ( char to string?

Hi,
I am trying to write ( char to string, but it didnt work, i tried regular string “(”, ecaping it “(” and also this [[(]], but nothing works. Can you help me?

Can you share your code? I’m not entirely sure what you mean by your question. You don’t need to escape parentheses in strings. They’re characters just like any others.

What exactly are you trying to accomplish?

I want to split parametr from command, so i am using this line to find ( char

local paramStart = string.find(functionName,"(")

but it is giving this error
[17:08:31.215 - ServerScriptService.Game.Electro.Orange L:26: unfinished capture]

Oh I see. Yeah, so for string captures you do have to escape such characters, since they’re used for patterns. You can use a “%” to escape it:

local paramStart = string.find(functionName, "%(")

Also, you can find everything within a set of parentheses using %b:

local capture = string.find(functionName, "%b()")
4 Likes

You can also disable string patterns with the plain argument of string.find

string.find(s, "(", 1, true)

The 1 is there since it’s the init, you have to provide it because the plain argument is the last argument

but crazyman32 has a good solution especially with the %b() if you need to know what’s inside the parentheses

2 Likes

And can i do this with more chars begining and ending?