[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Quiz question on string matching
- From: Paul K <paul@...>
- Date: Fri, 29 Jan 2016 05:50:18 +0000
> 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
>