[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: is this behavior correct?
- From: Peter Cawley <lua@...>
- Date: Mon, 13 Jun 2011 12:26:11 +0100
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.