lua-users home
lua-l archive

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


Thu, 16 Jul 2015 12:16:08 +0200 Dirk Laurie <dirk.laurie@gmail.com>

>We are dealing with two different concepts here.

>1. Anchors ^ and $, implemented. These tell the find/match/substitute
routines that the pattern should only be tested for at >respectively the
beginning or the end of the subject.

>2. Character classes %^ and %$, proposed. These represent an empty string
at respectively the beginning or the end of the >subject. This breaks the
rule that %x means literally x when x is non-alphanumeric, which IMHO
overrules the regularity >argument, so I would prefer to denote these, too,
by just ^ and $.

Ha, the irony! I want two different symbols for (what I claim is) the same
concept, you claim there are two concepts but that they should be
represented by the same symbols!

If we take your notation for the moment, you can conceptualise the anchors
as character classes and it still works:

"^John"

Is the literal sequence [start-of-subject].."John".

"John^Hind"

Can never match anything because there can never be anything before the
start of subject string, but can still be legal for conceptual regularity.

"[:^]John"

Means "John" either at the start of subject or following a colon (new
expressivity).

But the last cannot be written the other way round because of the ambiguity
with set inversion. I agree however that %^ and %$ is not a good idea
because of the escaping convention for special characters. Maybe %< and %>
would be better and would have some mnemonic value (admittedly the
documentation does not allow this at present, but your suggestion has the
same problem)? Or maybe as you say just "^" and "$" are better with a note
to avoid the ambiguity when specifying a set. It does have the advantage of
compatibility with the existing anchors.

>The proposal, whether with or without, does not seem terribly hard to
implement. We could get some hands-on experience >on them instead of making
the capital mistake of theorizing without data.
>Power patch, anyone?

Fair point, I do not have time at present, but if no one has done it when
things next go quiet I'll give it a go!



---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus