I need to find if a string start with 0 or more spaces followed by a comment string I don't know in advance, so I though of just constructing the pattern:
local pattern = "^(%s" .. comment_string .. ")"
if str:find(pattern) then
-- ...
The problem is that comment_string
contains metacharacters most of the time (i.e. for lua I get "--"
but I need "%-%-"
for the pattern to work). I tried a bunch of things but I can't find a way to make it work. Any idea?