lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]




On 2017-10-10 10:54 PM, Martin wrote:
On 10/10/2017 10:43 PM, Soni L. wrote:
However, I noticed something kinda weird:

string.match("''", "%f[']'", 2) --> nil
string.match("''", "^'", 2) --> '
string.match("''", "%f[']'", 2). From position 2 of string [['']]
locate to index <i> such that s[i] ~= [[']] and s[i + 1] == [[']] and
s[i + 1] == [[']].

There is no such index so nil is returned. In case of string [['' ']]
there is match.

string.match("''", "^'", 2). From position 2 of string [['']] find
string [[']]. Do not skip characters (due "^" anchor). This matches
[[']], second apostrophe.

-- Martin


But from position 1, the first pattern matches. From reading the manual, both operate on the start of the subject string, so either the first should match or the second should fail.

--
Disclaimer: these emails may be made public at any given time, with or without reason. If you don't agree with this, DO NOT REPLY.