Problem with capturing string using string.gsub()

So I’m making a syntax highlighting with string.gsub and richtext. But the problem is when I capture a string

print("Hello World\"")

It capture this

Hello World\

instead of

Hello World\"
print("Hello World\\")

“Hello World/“ is a full string, adding another quotation attempts to start another string, but it is never ended, id recommend doing;

print(‘Hello World/“‘)

i’m pretty sure this would work because the “ is wrapped inside of the string created with ‘

1 Like

Post the relevant code, there’s no way to tell what the full story is from just printing a string.

If you want to have a literal \ in a string then you need to escape them with another \.

print("Hello World\\\"") -- Hello World\"

1 Like

I found a way to fix it. Thank guys.