From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 16934 invoked from network); 12 Sep 2022 04:27:15 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 12 Sep 2022 04:27:15 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1662956835; b=P6Sq7uAnVJHF4Y2hSB5l/2XmdsScP+d9WfuU6CbmZgzDmOJLGLIcIagpb4yPm5KDgQEnkDBtGt LGzTLaIQG8VnGakZriMfJMbEoQwz/bNm1IHbdc7D/aCRUo2C05KXHqb53YLHZROWC1Pf1I3OOA xf5j3e+Ba14i293QR1LiKXBRcS/TVTxt3s7umhFWBFl1lQQ7M+d0STz1xlA8QKN2S+n9VGgvLb S2DEp2DW0krmhrELmnbh8IDiDIKFokAkl8T2Wt6OV50TOSNJ3OHpnHS26cucm3cTWYNnvztUtd FfVIQPO0PxsPA5eM/57lawB/236srE1vaiC9MneIrXnaqQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-pg1-f178.google.com) smtp.remote-ip=209.85.215.178; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1662956835; bh=6l18KK7kQa9Vi/CduziozP9de2JOTDzbvwPSe0kNcAc=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:To:Subject:Message-ID:Date:From:MIME-Version: DKIM-Signature:DKIM-Signature; b=nAzOck7ZiwMNiiOdgcnUkFUdZBImkWlMbOBOBjZUD2FnNuYJkobFS4WrDxkhvjmPFrb9Gr5lUu ihj2OnfJXsFueFGrCW6z6eAwbYFFFHJzckSLa0ZpDmpkYC9qNW1lSfaeoaafd1OAndTsWuYY9Z /Y15dJ+kFi1XL8CFqvp4tif/U6IcOWZwRxgRj8zte6UoxmO/sj+6Mm0VKEIoVJnNoJGb43MS4N naMRWUQiq57AnoIE8/Fc7+N57R7JGzNABAgzhKasO8nIIVKy0RUnuPoF/PQ8PT+q5pckxeGgGj NSlSmSn128Cl2yIp4/Q57Y1HUSICT2ccdJkaYOp/WAxQKg==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:To:Subject:Message-ID: Date:From:MIME-Version:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References; bh=zprnlbw6TyjusYmoTdo/MHA79iG3hxq89AC10mJEUCw=; b=ZqDXD61x9HqgBCHPQV7t/qhaTC fcKXTRSY0Wp9LPvszPK+fN673gigrLrZlGI7N0jyCdw1nlmn02ym9jW6RFqozBDPXEW6iHx48ipBh mHARH+/bfFm9mTP/fLuZgi2Rm/3HRtn1d52iogkj+TkWzC/ES8NcmtnZLkKW6NLtQiJpHZoKu/AU+ oxDsoryqGiGs4odljlJKgTE3UyIbq1snGpKfUe8DuVxAxkci2pE1mCIPOmAr779UwWi5FEQmGTtZs cPZJ4hQJ8v9K2CFOqqSjW57XQ5nFuCPRATnwgJRSaVpsPinnXk48TnL3ENecGgDkarFBSYPSYCu+D 5IhfSUSQ==; Received: from authenticated user by zero.zsh.org with local id 1oXb2P-000Hhp-Kx; Mon, 12 Sep 2022 04:27:13 +0000 Authentication-Results: zsh.org; iprev=pass (mail-pg1-f178.google.com) smtp.remote-ip=209.85.215.178; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-pg1-f178.google.com ([209.85.215.178]:38616) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1oXawb-000Gui-P8; Mon, 12 Sep 2022 04:21:14 +0000 Received: by mail-pg1-f178.google.com with SMTP id t70so7131801pgc.5 for ; Sun, 11 Sep 2022 21:21:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date; bh=zprnlbw6TyjusYmoTdo/MHA79iG3hxq89AC10mJEUCw=; b=dC+REGZT2ZiWWN5Ipc/P8CZFHqyLeyvowT6HwFadPDfvV9JQi10bhZvL1YFFz9vYvE 7JSBukrqMoArKRoM34px4T/wxp5QepX4LNoWtVpoOs0Wih6VTNLYfmyazTEiYNsPaAUi whAfKWD8KSzNzJHkCt9KDqRuiInFDqIFVbTRa2xcRrpK79wSiiuY/VEWwYdwc0oeULsT aD78jLYsoY88UWKI5QD0xi5Rr+n5wL8gB4827DGfGBWxkLUcXH+sBWFlIPvLI3cgk7IZ 9O9DE6TTPN79t51wJ/WtLn16nqRvexsn6T+lQg85T7zmAXW4SWY3zh6cDqgVR6ojpUBU il6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date; bh=zprnlbw6TyjusYmoTdo/MHA79iG3hxq89AC10mJEUCw=; b=SIu0XUXDUp+18cFjDaFuzQJ+aptOxSQ7yNSd2KSbtqfUTF6yvXbxxvFnVvirjlmRrL gopNtcm7/t1o4NVjJ69WUKV1ue0yN7M+jva7/LvoUgprfWJTJaouYQILBtV4glj5lTC+ OlAfHUhs5SteCETgbLL4CWxXMN3L6Zou/s0GgtBXiwm9rt192VqSUi37KzxFZVYvrr0A JCI6GGnXXH80tQcj1bMEmySMgFaMzOI/8EHyRPuxxUSK5pV+UK1321yyMiw353bL4saF 0J+1Ltrp878U5NCERGoPI60wqYR2tOsKv7kgPmwyTDDV8AfDIB93iTE9DHvL+m8kRbDh E61A== X-Gm-Message-State: ACgBeo2E+Z9VxGyiGrRsIMSW289TeKvvIN2fqTcJxNf2uYAKvb2pvXTu lxdLkexchyIT1/MAls0XP2GTulsjEDT8IkJCbzLFD9H2OmUAsQ== X-Google-Smtp-Source: AA6agR5qg35z8jBCoIQAnXrPSUJ8XHgQTeYKp38nNdmpOb0XijFrG5MVbe5m3DY+9qOaqA0grf16vwEolLg2wFg4e5I= X-Received: by 2002:a05:6a00:1909:b0:536:65dd:44ca with SMTP id y9-20020a056a00190900b0053665dd44camr26194168pfi.1.1662956471688; Sun, 11 Sep 2022 21:21:11 -0700 (PDT) MIME-Version: 1.0 From: Michele Venturi Date: Mon, 12 Sep 2022 06:20:35 +0200 Message-ID: Subject: Substitute the last match of a pattern during parameters expansion. To: zsh-users@zsh.org Content-Type: multipart/alternative; boundary="000000000000c5a61e05e8733978" X-Seq: 28061 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: --000000000000c5a61e05e8733978 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello, I have a problem, can you help me? I would like to substitute the last match of a pattern during parameters expansion=E2=80=A6 The string aXbXc should become aXbYc; I have not found a direct and general way of doing it, but there are some solutions=E2=80=A6 The problem is that they are cumbersome: ${str%X*}Y${str##*X} is too convoluted for such a simple operation in my opinion, no? Hard-coding a number like in ${(I:2:)str/X/Y} is usually not a good idea, don=E2=80=99t you agree? Other possibilities have similar down sides. So is there an easier way to get the desired result or should it be added to the software and how complicated would be to change it? I would suggest a new flag like % or $ for it. I wonder if the syntax ${(%)str/X/Y} is going to conflict with other functionalities of ZSH=E2=80=A6 Obviously adding negative indexes support to the I flag would be very good but verbose for the most common use case of that, right? What do you think about this whole matter? What should I learn to find out how to do it? Your thoughts on the topic are appreciated=E2=80=A6 Michele Venturi about.me/dardo82 --000000000000c5a61e05e8733978 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello= , I have a problem, can you help me?
I would like to substitute the last match=C2=A0of
=
a=C2=A0pattern during p= arameters expansion=E2=80=A6
The st= ring aXbXc should become aXbYc;
I have not found a direct and general way
of doing it, but there are some solut= ions=E2=80=A6

=
The problem is th= at they are cumbersome:
${str%X*}Y${str##*X} is too convoluted for
such a simple operation in my opinion, no?

Hard-coding a number like in ${(= I:2:)str/X/Y}
is u= sually not a good idea, don=E2=80=99t you agree?
Other possibilities have similar down sides.=

So is there an easier way to g= et the desired
res= ult or should it be added to the software
and how complicated would be to change it?

I would suggest a new flag like % or $ = for it.
I wonder i= f the syntax ${(%)str/X/Y} is going
to conflict with other functionalities of ZSH=E2=80=A6

Obviously adding negative indexes= support
to the I= =C2=A0flag would be very good but verbose
for the most common use case of that, right?
<= div style=3D"color:rgb(34,35,31);font-family:"Source Sans Pro",He= lvetica,sans-serif;font-size:14.399999618530273px">
What do you think about this whole ma= tter?
What should = I learn to find out how to do it?
Your thoughts on the topic are appreciated=E2=80=A6

3D""
M= ichele Venturi
about.me/dardo82
--000000000000c5a61e05e8733978--