Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

To understand a program you must become both the machine and the program.


devel / comp.unix.shell / Re: why is $ not literal mid-string in an ERE?

SubjectAuthor
* why is $ not literal mid-string in an ERE?Ed Morton
+* why is $ not literal mid-string in an ERE?Oğuz
|`- why is $ not literal mid-string in an ERE?Ed Morton
+* why is $ not literal mid-string in an ERE?Helmut Waitzmann
|`- why is $ not literal mid-string in an ERE?Ed Morton
`* why is $ not literal mid-string in an ERE?Kaz Kylheku
 `- why is $ not literal mid-string in an ERE?Ed Morton

1
why is $ not literal mid-string in an ERE?

<tdleoh$11psc$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6685&group=comp.unix.shell#6685

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: mortonspam@gmail.com (Ed Morton)
Newsgroups: comp.unix.shell
Subject: why is $ not literal mid-string in an ERE?
Date: Thu, 18 Aug 2022 08:27:46 -0500
Organization: A noiseless patient Spider
Lines: 66
Message-ID: <tdleoh$11psc$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 18 Aug 2022 13:27:45 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="867f4a4236175118b1d2a95cd2ca87e4";
logging-data="1107852"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/qdQWeVXuL9Oe5cT0iFcB0"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.1.0
Cancel-Lock: sha1:nB4Cjbt1nTA0d69g9sbT+LgwXHU=
X-Antivirus: Avast (VPS 220817-6, 8/17/2022), Outbound message
Content-Language: en-US
X-Antivirus-Status: Clean
 by: Ed Morton - Thu, 18 Aug 2022 13:27 UTC

When I write a regexp that has a `$` in the middle of it I write it as
either of:

sed 's/foo\$bar/stuff/'
sed 's/foo[$]bar/stuff/'

so that it's clear the `$` should be treated literally. Given that, I've
never noticed before that an unescaped `$` mid-regexp is treated
differently in BREs vs EREs, e.g.:

$ echo 'foo$bar' | sed 's/foo$bar/stuff/'
stuff

$ echo 'foo$bar' | sed -E 's/foo$bar/stuff/'
foo$bar

As far as I can see, the relevant quotes of the POSIX spec
(https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html)
for BREs are:

-----
$ The <dollar-sign> shall be special when used as an anchor.

A <dollar-sign> ( '$' ) shall be an anchor when used as the last
character of an entire BRE. The implementation may treat a <dollar-sign>
as an anchor when used as the last character of a subexpression. The
<dollar-sign> shall anchor the expression (or optionally subexpression)
to the end of the string being matched; the <dollar-sign> can be said to
match the end-of-string following the last character.
-----

and for EREs (emphasis mine):

-----
$ The <dollar-sign> shall be special when used as an anchor.

A <dollar-sign> ( '$' ) outside a bracket expression shall anchor the
expression or subexpression it ends to the end of a string; such an
expression or subexpression can match only a sequence ending at the last
character of a string. For example, the EREs "ef$" and "(ef$)" match
"ef" in the string "abcdef", but fail to match in the string "cdefab",
and **the ERE "e$f" is valid, but can never match because the 'f'
prevents the expression "e$" from matching ending at the last character**.
-----

So, the BRE section doesn't explicitly state what `$` means when it's
not at the end of a regexp but given the "special when used as an
anchor" statement, it makes sense to take that as meaning it's literal
otherwise and that is how the various tools I've tried are interpreting it.

The ERE section, however, has that same statement about `$` being
special when used as an anchor, but then goes on to state that when it's
mid-regexp, e.g. `e$f`, it should NOT be treated literally even though
doing so means the regexp that includes it can never match anything.

That ERE specification seems odd - why interpret `$` in a way that's
different from BREs and results in a regexp that can never match
anything instead of simply treating it as literal, same as BREs do?

Does anyone have any insight into why a `$` mid-regexp is treated that
way in EREs?

Ed.

Re: why is $ not literal mid-string in an ERE?

<tdm0e0$14nmd$1@oguzismail.eternal-september.org>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6686&group=comp.unix.shell#6686

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!oguzismail.eternal-september.org!.POSTED!not-for-mail
From: oguzismailuysal@gmail.com (Oğuz)
Newsgroups: comp.unix.shell
Subject: Re: why is $ not literal mid-string in an ERE?
Date: Thu, 18 Aug 2022 21:29:19 +0300
Organization: A noiseless patient Spider
Lines: 18
Message-ID: <tdm0e0$14nmd$1@oguzismail.eternal-september.org>
References: <tdleoh$11psc$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 18 Aug 2022 18:29:21 -0000 (UTC)
Injection-Info: oguzismail.eternal-september.org; posting-host="c33cec02ecda6206a3186418a6daf08d";
logging-data="1203917"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19sSOz+eu9Bd5tsGcoWcclPtUC/MGBXUFE="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.11.0
Cancel-Lock: sha1:RhXYoLDCi34XcSX6XRcpdyn6bbg=
In-Reply-To: <tdleoh$11psc$1@dont-email.me>
Content-Language: en-US
 by: Oğuz - Thu, 18 Aug 2022 18:29 UTC

On 8/18/22 4:27 PM, Ed Morton wrote:
> That ERE specification seems odd - why interpret `$` in a way that's
> different from BREs and results in a regexp that can never match
> anything instead of simply treating it as literal, same as BREs do?

The standard simply documents existing practice here. Under XRAT A.9.3.8
it says:

> The ability of '^', '$', and '*' to be non-special in certain circumstances may be confusing to
> some programmers, but this situation was changed only in a minor way from historical practice
> to avoid breaking many historical scripts. Some consideration was given to making the use of
> the anchoring characters undefined if not escaped and not at the beginning or end of strings.
> This would cause a number of historical BREs, such as "2^10", "$HOME", and "$1.35", that
> relied on the characters being treated literally, to become invalid.
> ERE anchoring has been different from BRE anchoring in all historical systems. An unescaped
> anchor character has never matched its literal counterpart outside a bracket expression. Some
> implementations treated "foo$bar" as a valid expression that never matched anything; others
> treated it as invalid. POSIX.1-202x mandates the former, valid unmatched behavior.

Re: why is $ not literal mid-string in an ERE?

<tdm19v$14prs$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6687&group=comp.unix.shell#6687

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: mortonspam@gmail.com (Ed Morton)
Newsgroups: comp.unix.shell
Subject: Re: why is $ not literal mid-string in an ERE?
Date: Thu, 18 Aug 2022 13:44:17 -0500
Organization: A noiseless patient Spider
Lines: 41
Message-ID: <tdm19v$14prs$1@dont-email.me>
References: <tdleoh$11psc$1@dont-email.me>
<tdm0e0$14nmd$1@oguzismail.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 18 Aug 2022 18:44:15 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="fe1f83c9dfa78936f291cc5f58cd15ad";
logging-data="1206140"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/kR12x74nFpXtNYdCpVFg7"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.1.0
Cancel-Lock: sha1:KLFpsq2xbfUvjSGCpiifEh56k8w=
X-Antivirus-Status: Clean
X-Antivirus: Avast (VPS 220818-14, 8/18/2022), Outbound message
In-Reply-To: <tdm0e0$14nmd$1@oguzismail.eternal-september.org>
Content-Language: en-US
 by: Ed Morton - Thu, 18 Aug 2022 18:44 UTC

On 8/18/2022 1:29 PM, Oğuz wrote:
> On 8/18/22 4:27 PM, Ed Morton wrote:
>> That ERE specification seems odd - why interpret `$` in a way that's
>> different from BREs and results in a regexp that can never match
>> anything instead of simply treating it as literal, same as BREs do?
>
> The standard simply documents existing practice here. Under XRAT A.9.3.8
> it says:

OK, I see that at:

https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xbd_chap09.html#tag_21_09_03_08

>
>> The ability of '^', '$', and '*' to be non-special in certain
>> circumstances may be confusing to
>> some programmers, but this situation was changed only in a minor way
>> from historical practice
>> to avoid breaking many historical scripts. Some consideration was
>> given to making the use of
>> the anchoring characters undefined if not escaped and not at the
>> beginning or end of strings.
>> This would cause a number of historical BREs, such as "2^10", "$HOME",
>> and "$1.35", that
>> relied on the characters being treated literally, to become invalid.
>> ERE anchoring has been different from BRE anchoring in all historical
>> systems. An unescaped
>> anchor character has never matched its literal counterpart outside a
>> bracket expression. Some
>> implementations treated "foo$bar" as a valid expression that never
>> matched anything; others
>> treated it as invalid. POSIX.1-202x mandates the former, valid
>> unmatched behavior.

Them discussing `foo$bar` in that article when I used that exact string
in my question is quite a coincidence!

Thanks,

Ed.

Re: why is $ not literal mid-string in an ERE?

<83tu69k0c6.fsf@helmutwaitzmann.news.arcor.de>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6688&group=comp.unix.shell#6688

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!aioe.org!zh62+Qmv5nXStwYROZ6YcA.user.46.165.242.75.POSTED!not-for-mail
From: nn.throttle@xoxy.net (Helmut Waitzmann)
Newsgroups: comp.unix.shell
Subject: Re: why is $ not literal mid-string in an ERE?
Date: Thu, 18 Aug 2022 18:01:13 +0200
Organization: Aioe.org NNTP Server
Message-ID: <83tu69k0c6.fsf@helmutwaitzmann.news.arcor.de>
References: <tdleoh$11psc$1@dont-email.me>
Reply-To: Helmut Waitzmann Anti-Spam-Ticket.b.qc3c <oe.throttle@xoxy.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable
Injection-Info: gioia.aioe.org; logging-data="17838"; posting-host="zh62+Qmv5nXStwYROZ6YcA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)
Mail-Copies-To: nobody
Mail-Reply-To: Helmut Waitzmann Anti-Spam-Ticket.b.qc3c <oe.throttle@xoxy.net>
X-Notice: Filtered by postfilter v. 0.9.2
Cancel-Lock: sha1:vkEfaVLnhug9qcV5Nmb+T/r0Yl8=
 by: Helmut Waitzmann - Thu, 18 Aug 2022 16:01 UTC

Ed Morton <mortonspam@gmail.com>:

>When I write a regexp that has a `$` in the middle of it I write it
>as either of:
>
> sed 's/foo\$bar/stuff/'
> sed 's/foo[$]bar/stuff/'
>
>so that it's clear the `$` should be treated literally. Given that,
>I've never noticed before

So do I.

>that an unescaped `$` mid-regexp is treated differently in BREs vs
>EREs, e.g.:
>
> $ echo 'foo$bar' | sed 's/foo$bar/stuff/'
> stuff
>
> $ echo 'foo$bar' | sed -E 's/foo$bar/stuff/'
> foo$bar
>
>As far as I can see, the relevant quotes of the POSIX spec
>(https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html)
>for BREs are:
>
>-----
>$
> The <dollar-sign> shall be special when used as an anchor.
>
>A <dollar-sign> ( '$' ) shall be an anchor when used as the last
>character of an entire BRE. The implementation may treat a
><dollar-sign> as an anchor when used as the last character of a
>subexpression. The <dollar-sign> shall anchor the expression (or
>optionally subexpression) to the end of the string being matched; the
><dollar-sign> can be said to match the end-of-string following the
>last character.
>-----
>
>and for EREs (emphasis mine):
>
>-----
>$
> The <dollar-sign> shall be special when used as an anchor.
>
>A <dollar-sign> ( '$' ) outside a bracket expression shall anchor the
>expression or subexpression it ends to the end of a string; such an
>expression or subexpression can match only a sequence ending at the
>last character of a string. For example, the EREs "ef$" and "(ef$)"
>match "ef" in the string "abcdef", but fail to match in the string
>"cdefab", and **the ERE "e$f" is valid, but can never match because
>the 'f' prevents the expression "e$" from matching ending at the last
>character**.
>-----
>
>So, the BRE section doesn't explicitly state what `$` means when
>it's not at the end of a regexp but given the "special when used as
>an anchor" statement, it makes sense to take that as meaning it's
>literal otherwise and that is how the various tools I've tried are
>interpreting it.
>
>The ERE section, however, has that same statement about `$` being
>special when used as an anchor, but then goes on to state that when
>it's mid-regexp, e.g. `e$f`, it should NOT be treated literally
>even though doing so means the regexp that includes it can never
>match anything.
>
>That ERE specification seems odd - why interpret `$` in a way
>that's different from BREs and results in a regexp that can never
>match anything instead of simply treating it as literal, same as
>BREs do?
>

I feel it the other way round:  The BRE specification seems odd: 
Why should an unescaped unbracketed dollar sign only be interpreted
special when it's at the end of an expression?  (That constraint
doesn't harm, though, because a dollar sign one wants to have its
literal meaning can be escaped or bracketed even when not at the end
of an expression.)

>Does anyone have any insight into why a `$` mid-regexp is treated
>that way in EREs?

I don't know, but I guess it's the principle “Keep it simple”:  A
dollar‐sign ist special, unless it is either inside a bracket
expression or preceded be a quoting backslash.  There is no
additional constraining rule “unless it is inside of an expression”,
which is unnecessary to bring dollar signs with their literal
meaning into regular expressions.

And I guess with BREs it was too late to abandon that constraining
rule without breaking existing utilities.

But that all is just a guess.

Re: why is $ not literal mid-string in an ERE?

<tdm84b$15fvm$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6689&group=comp.unix.shell#6689

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: mortonspam@gmail.com (Ed Morton)
Newsgroups: comp.unix.shell
Subject: Re: why is $ not literal mid-string in an ERE?
Date: Thu, 18 Aug 2022 15:40:43 -0500
Organization: A noiseless patient Spider
Lines: 103
Message-ID: <tdm84b$15fvm$1@dont-email.me>
References: <tdleoh$11psc$1@dont-email.me>
<83tu69k0c6.fsf@helmutwaitzmann.news.arcor.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 18 Aug 2022 20:40:43 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="fe1f83c9dfa78936f291cc5f58cd15ad";
logging-data="1228790"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/4JR2fVPdpb7pYnl/dHDuz"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.1.0
Cancel-Lock: sha1:dh9iS2NhwrkA/uHdxRQiiwmsa8I=
In-Reply-To: <83tu69k0c6.fsf@helmutwaitzmann.news.arcor.de>
X-Antivirus: Avast (VPS 220818-14, 8/18/2022), Outbound message
X-Antivirus-Status: Clean
Content-Language: en-US
 by: Ed Morton - Thu, 18 Aug 2022 20:40 UTC

On 8/18/2022 11:01 AM, Helmut Waitzmann wrote:
> Ed Morton <mortonspam@gmail.com>:
>
>> When I write a regexp that has a `$` in the middle of it I write it as
>> either of:
>>
>>    sed 's/foo\$bar/stuff/'
>>    sed 's/foo[$]bar/stuff/'
>>
>> so that it's clear the `$` should be treated literally. Given that,
>> I've never noticed before
>
> So do I.
>
>> that an unescaped `$` mid-regexp is treated differently in BREs vs
>> EREs, e.g.:
>>
>>    $ echo 'foo$bar' | sed 's/foo$bar/stuff/'
>>    stuff
>>
>>    $ echo 'foo$bar' | sed -E 's/foo$bar/stuff/'
>>    foo$bar
>>
>> As far as I can see, the relevant quotes of the POSIX spec
>> (https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html) for BREs are:
>>
>> -----
>> $
>>    The <dollar-sign> shall be special when used as an anchor.
>>
>> A <dollar-sign> ( '$' ) shall be an anchor when used as the last
>> character of an entire BRE. The implementation may treat a
>> <dollar-sign> as an anchor when used as the last character of a
>> subexpression. The <dollar-sign> shall anchor the expression (or
>> optionally subexpression) to the end of the string being matched; the
>> <dollar-sign> can be said to match the end-of-string following the
>> last character.
>> -----
>>
>> and for EREs (emphasis mine):
>>
>> -----
>> $
>>    The <dollar-sign> shall be special when used as an anchor.
>>
>> A <dollar-sign> ( '$' ) outside a bracket expression shall anchor the
>> expression or subexpression it ends to the end of a string; such an
>> expression or subexpression can match only a sequence ending at the
>> last character of a string. For example, the EREs "ef$" and "(ef$)"
>> match "ef" in the string "abcdef", but fail to match in the string
>> "cdefab", and **the ERE "e$f" is valid, but can never match because
>> the 'f' prevents the expression "e$" from matching ending at the last
>> character**.
>> -----
>>
>> So, the BRE section doesn't explicitly state what `$` means when it's
>> not at the end of a regexp but given the "special when used as an
>> anchor" statement, it makes sense to take that as meaning it's literal
>> otherwise and that is how the various tools I've tried are
>> interpreting it.
>>
>> The ERE section, however, has that same statement about `$` being
>> special when used as an anchor, but then goes on to state that when
>> it's mid-regexp, e.g. `e$f`, it should NOT be treated literally even
>> though doing so means the regexp that includes it can never match
>> anything.
>>
>> That ERE specification seems odd - why interpret `$` in a way that's
>> different from BREs and results in a regexp that can never match
>> anything instead of simply treating it as literal, same as BREs do?
>>
>
> I feel it the other way round:  The BRE specification seems odd: Why
> should an unescaped unbracketed dollar sign only be interpreted special
> when it's at the end of an expression?  (That constraint doesn't harm,
> though, because a dollar sign one wants to have its literal meaning can
> be escaped or bracketed even when not at the end of an expression.)
>
>> Does anyone have any insight into why a `$` mid-regexp is treated that
>> way in EREs?
>
> I don't know, but I guess it's the principle “Keep it simple”:  A
> dollar‐sign ist special, unless it is either inside a bracket expression
> or preceded be a quoting backslash.  There is no additional constraining
> rule “unless it is inside of an expression”, which is unnecessary to
> bring dollar signs with their literal meaning into regular expressions.

Right but there's other characters that are treated as metachars based
on context, e.g. `}`, `]`, and `)` are only metachars if they succeed
`{`, `[`, and `(` respectively, otherwise they're literal, and `^`, `-`
and `]` mean different things depending on where they appear inside a
bracket expression, so it wouldn't be much of a leap to make the meaning
of `^` and `$` outside of a bracket expression context-sensitive too.

Ed.

>
> And I guess with BREs it was too late to abandon that constraining rule
> without breaking existing utilities.
>
> But that all is just a guess.

Re: why is $ not literal mid-string in an ERE?

<20220819102742.413@kylheku.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6692&group=comp.unix.shell#6692

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: 480-992-1380@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.shell
Subject: Re: why is $ not literal mid-string in an ERE?
Date: Fri, 19 Aug 2022 17:34:15 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <20220819102742.413@kylheku.com>
References: <tdleoh$11psc$1@dont-email.me>
Injection-Date: Fri, 19 Aug 2022 17:34:15 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="ea9c24edd1417c67e184f609f3736497";
logging-data="1670869"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18lRoJNPjf83wYHLA90hRSpVZCr0PLGvKg="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:DaAGj0XK97snMT0d7Z1hc2b0m1A=
 by: Kaz Kylheku - Fri, 19 Aug 2022 17:34 UTC

On 2022-08-18, Ed Morton <mortonspam@gmail.com> wrote:
> When I write a regexp that has a `$` in the middle of it I write it as
> either of:
>
> sed 's/foo\$bar/stuff/'
> sed 's/foo[$]bar/stuff/'

Because $ can have the special anchoring meaning, even when
it occurs in the middle of a regex:

$ grep -E 'abc$|def'

matches lines ending in abc, or containing def.

To get the behavior you want, the exact rule would have to be
rooted in the abstract syntax: that a $ which has a right
sibling in the syntax tree becomes automatically literal.

> so that it's clear the `$` should be treated literally. Given that, I've

Treating characters literally or not based on their position in the
syntax is a bad idea in the first place.

For instance it's a misfeature some regex implementatons that ) becomes
literal, without escaping, if it is unmatched, rather than being
flagged as a syntax error.

Consistency is best.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal

Re: why is $ not literal mid-string in an ERE?

<tdp9uc$1lojm$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6693&group=comp.unix.shell#6693

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: mortonspam@gmail.com (Ed Morton)
Newsgroups: comp.unix.shell
Subject: Re: why is $ not literal mid-string in an ERE?
Date: Fri, 19 Aug 2022 19:30:05 -0500
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <tdp9uc$1lojm$1@dont-email.me>
References: <tdleoh$11psc$1@dont-email.me> <20220819102742.413@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 20 Aug 2022 00:30:04 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="cfa1dc0cabdad95fc56bcbc6f7bd4363";
logging-data="1761910"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ZtjWuQlv8d4PCYDmeZoo4"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.1.0
Cancel-Lock: sha1:qnVuWMZcd5oWFQGJTCL7+Et3CKs=
X-Antivirus-Status: Clean
Content-Language: en-US
In-Reply-To: <20220819102742.413@kylheku.com>
X-Antivirus: Avast (VPS 220819-8, 8/19/2022), Outbound message
 by: Ed Morton - Sat, 20 Aug 2022 00:30 UTC

On 8/19/2022 12:34 PM, Kaz Kylheku wrote:
> On 2022-08-18, Ed Morton <mortonspam@gmail.com> wrote:
>> When I write a regexp that has a `$` in the middle of it I write it as
>> either of:
>>
>> sed 's/foo\$bar/stuff/'
>> sed 's/foo[$]bar/stuff/'
>
> Because $ can have the special anchoring meaning, even when
> it occurs in the middle of a regex:
>
> $ grep -E 'abc$|def'
>
> matches lines ending in abc, or containing def.

All the relevant ERE text actually talks about regexp subexpressions in
the same way the BRE text talks about whole regexps, I just didn't want
to get into that, so in the above case the $ is at the end of a
subexpression and so the $ is being treated consistently between BREs
and EREs in that regard.

Ed.

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor