On Mon, Jun 13, 2011 at 12:23 PM, Xavier Wang<weasley.wx@gmail.com> wrote:
local s = "abcdef"
print(string.match(s, "(^abc)(def$)"))
shows "nil"
but:
local s = "abcdef"
print(string.match(s, "^(abc)(def)$"))
shows "abc def"
is this behavior correct?
According to the manual, yes:
A '^' at the beginning of a pattern anchors the match at the beginning
of the subject string. A '$' at the end of a pattern anchors the match
at the end of the subject string. At other positions, '^' and '$' have
no special meaning and represent themselves.