"x-"
is a special pattern. It does not mean an x followed by a hyphen. It means "0 or more "x"
(but as few as possible)".
When you used a hyphen in your pattern, you meant the first, but Lua understands it as the second.
Similarly, [abc]
is a pattern. It defines a character class, meaning one of a
, b
, or c
.
When you used [
, you meant it as a literal square bracket, but that's not how Lua understands it.
.
is also a special character (meaning anything).
This one's probably not a problem, but it's also not what you mean. If there was a q
there instead of a .
, Lua would accept that.
You need to escape these special characters with %
, such as %-
or %[
or %.
. This means that they are the literal character, e.g., %-
matches a hyphen, not zero or more percent signs.
You can also use ()
to capture just the version, instead of using tostring
and match
1 | [[<h1 class="game%-name" title="Defend! %[(%d+%.%d+%.%d+)%] %[Public InDev%]">Defend! %[0%.2%.5%] %[Public InDev%]</h1>]] |