9front - general discussion about 9front
 help / color / mirror / Atom feed
From: ieliedonge@wilsonb.com
To: 9front@9front.org
Subject: Re: [9front] sed: fix moving '^' match
Date: Sun, 27 Aug 2023 20:19:58 +0900	[thread overview]
Message-ID: <2T2PTG8EZ3I9B.3O4VG56AQWFN6@wilsonb.com> (raw)
In-Reply-To: <ZOsdUtPonBvOZ4tl@polynum.com>

> > we must be disagreeing about some fundamental understanding instead.
> > it's hard for me to see still where *exactly* we differ.
>
> ...
>
> In some sense, this interpretation of 'g' is considering that 'g' makes an
> infinite looping of the regex, applied to the resulting string and that should
> only end if no modification is made. Seems incorrect to me.

Oh, nice! I believe you lasered in on the crux here. IIUC, hiro's mental model
seems to be that s///g induces a simple loop over the string where '^' can
match the beginning of string multiple times, while mine (and others'?) is that
g identifies all matches *before replacement*.

I'm not sure what *should* be in this case, but the latter interpretation is
definitely consistent with the 5 or so different regex implementations I
regularly interact with.

> The current behavior may be bug compatible with V8. It remains a bug
> IMHO.

Just gave V8 a spin:

    # echo aabbccd | sed 's/^..//g'
    bbccd

  reply	other threads:[~2023-08-27 11:27 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-25 21:46 ori
2023-08-26  0:04 ` [9front] " Anthony Martin
2023-08-26  9:14   ` hiro
2023-08-26 17:58     ` ori
2023-08-26 18:02     ` ori
2023-08-26  9:05 ` [9front] " hiro
2023-08-26  9:41   ` ieliedonge
2023-08-26 16:48     ` hiro
2023-08-26 18:00       ` ori
2023-08-26 23:23       ` ieliedonge
2023-08-27  8:33         ` hiro
2023-08-27  9:54           ` tlaronde
2023-08-27 11:19             ` ieliedonge [this message]
2023-09-23  1:35             ` ieliedonge
2023-09-23 10:30               ` hiro
2023-09-24 15:35               ` ori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2T2PTG8EZ3I9B.3O4VG56AQWFN6@wilsonb.com \
    --to=ieliedonge@wilsonb.com \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).