79613506

Date: 2025-05-09 05:03:21
Score: 0.5
Natty:
Report link

Be aware, # is not a special character, you do not need to escape it with %

The correct answer for your first question is lehtmi's, Using frontier pattern is the way to go, and yes it does work on latest 5.1 and luajit to make a match using string.match

string.match(str, "%f[^\n\r\0]###?[^#\r\n\0]+")

Should yield ##First line

How could I go about matching a pattern that starts with "line start" in Lua?

The simplest is to split the string into lines

for line in str:gmatch"[^\r\n]*[^\n]?" do
 if line:find"^###?.+" then -- stuff here
 end
end

Should be enough.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: Monev