lua-users home
lua-l archive

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


> Find a pattern with no captures such that putting it in parentheses may change what it matches.

testanswer("abc", "^.")
testanswer("abc", ".$")

Paul.

On Thu, Jan 28, 2016 at 9:41 PM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
>   Find a pattern with no captures such that putting it in parentheses
>   may change what it matches.
>
> More precisely:
>
>    Find strings `str` and `pat` such that `testanswer(str,pat)` prints
>    'true', where
>
> testanswer = function(str,pat)
> if pat:match"[()]" then return end
> print(str:match(pat) ~= str:match('(' .. pat .. ')'))
> end
>