Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is this gsub snippet printing numbers?

Asked by 8 years ago

I was looking through tutorials on the roblox wiki and I found that

print( string.gsub("hello world from Lua", "(%w+)%s*(%w+)", "%2 %1") )

would print

>world hello Lua from 2

What gets me here is the extra "2". The code is supposed to just rearrange the two captures, but why is it adding in extra?

Answer this question