[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Pattern matching proposal: %B to match balanced string with specified escape
- From: Jonathan Goble <jcgoble3@...>
- Date: Tue, 5 Jan 2016 04:51:24 -0500
On Tue, Jan 5, 2016 at 3:29 AM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> 2016-01-05 9:50 GMT+02:00 Rena <hyperhacker@gmail.com>:
>
>> I also wonder about using %b with the same character twice, like: %b"" - the
>> manual says it expects two different characters, but it'd be nice if we
>> could do this.
>
> I don't know why the manual says that. It works perfectly well with
> the same character twice.
>
>> string.match('abc"def"ghi"jkl"mno','%b""')
> "def"
And this proposal would make that even more powerful:
> str = [[char str[] = "this \"is\" a test"]]
> str
char str[] = "this \"is\" a test"
> str:match[[%B"\"]]
"this \"is\" a test"
Poof: instant matching of string literals with escape handling, in a
five-character pattern. How cool is that? :-)