String.gsub "invalid capture index"?

Hello!
I’m trying replace “%0A” in a string with nothing, so I tried this:

local bla = "This is %0A a string!"
bla = string.gsub(bla,"%0A","")
print(bla)

Although, I get the error “invalid capture index”, whilst the expected result is “This is a string!”

Why could this be?

Thanks in advance,
Jonas

1 Like

%0 is not a real capture command, which Lua thinks you want to do.

To escape a percent sign, you must use %%.

3 Likes

Alrighty! Would this work?:

local bla = "This is %0A a string!"
bla = string.gsub(bla,"%%0A","")
print(bla)

Yes.

Alrighty! Let me test! :slight_smile:

image

This is a new server (and I applied edits to the script)

EDIT: I was stupid and forgot to publish. Sorry!

Thanks a lot for your help!

1 Like