[TUHS] RegExp decision for meta characters: Circumflex

Rob Pike robpike at gmail.com
Fri Sep 17 19:32:28 AEST 2021


*NOT* the same. Sorry....

I hope the example explains better than my prose.

-rob


On Fri, Sep 17, 2021 at 7:32 PM Rob Pike <robpike at gmail.com> wrote:

> You'd have to ask ken why he chose the characters he did, but I can answer
> the second question. The beginning and end of line are the same. If you
> make ^ mean both beginning and end of line, what does this ed command do:
>
> s/^/x/
>
> Which end gets the x?
>
> -rob
>
>
> On Fri, Sep 17, 2021 at 7:00 PM markus schnalke <meillo at marmaro.de> wrote:
>
>> Hoi,
>>
>> I'm interested in the early design decisions for meta characters
>> in REs, mainly regarding Ken's RE implementation in ed.
>>
>> Two questions:
>>
>> 1) Circumflex
>>
>> As far as I see, the circumflex (^) is the only meta character that
>> has two different special meanings in REs: First being the
>> beginning of line anchor and second inverting a character class.
>> Why was it chosen for the second one? Why not the exclamation mark
>> in that case? (Sure, C didn't exist by then, but the bang probably
>> was used to negate in other languages of the time, I think.)
>>
>> 2) Symbol for the end of line anchor
>>
>> What is the reason that the beginning of line and end of line
>> anchors are different symbols? Is there a reason why not only one
>> symbol, say the circumflex, was chosen to represent both? I
>> currently see no disadvantages of such a design. (Circumflexes
>> aren't likely to end lines of text, neither.)
>>
>> I would appreciate if you could help me understand these design
>> decisions better. Maybe there existed RE notations that were simply
>> copied ...
>>
>>
>> meillo
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://minnie.tuhs.org/pipermail/tuhs/attachments/20210917/2629989b/attachment.htm>


More information about the TUHS mailing list