lua-users home
lua-l archive

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


Hi:


On Mon, Mar 3, 2014 at 9:53 PM, Pierre-Yves Gérardy <pygy79@gmail.com> wrote:
> On Mon, Mar 3, 2014 at 6:24 PM, Francisco Olarte <folarte@peoplecall.com> wrote:
>> I do not agree. string.find is trying to find AFTER the passed
>> position, not AT it, so it has its logic to clip it to 1, it's a
>> simple optimization. I.e, string length 5, you pass -7, string cannot
...
> This doesn't hold for anchored patterns.
>     p = "^aab"
>     s = "aabbaab"
>     s:find(p) --> 1, 3
>     s:find(p, -4) --> nil
>     s:find(p, -30) --> 1, 3 ... Whoops.

Would you care to elaborate? To me your example seems to demonstrate
it holds ( first one ok, second one does not find it as you cannot
find a start of string between 4 chars before the end of a 7 char
string and the end,  third one finds it as I said. You tell it to find
a start of string between 30 chars before the end ( 23 chars before
the start ) and the end and it finds it at the start.

Francisco Olarte.