Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Substitute the last match of a pattern during parameters expansion.

On Wed, Sep 14, 2022, 20:56 Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
On Tue, Sep 13, 2022 at 8:20 PM Michele Venturi <dardo82@xxxxxxxxx> wrote:
> Plus you seem good at non trivial tasks if you can
> write that monstrousity.Do you know what's trivial? > Counting, to know how many matches there are...

Definitely keep that approach and see
how much help it gets you in the future.

I'm the one helping you pointing out your weaknesses
and prodding you to get better,don't get confused,ok?

> There are examples of supporting negative index,
> so don't see a reason why it is so difficult to do it.

For benefit of other readers ...

So you are basically saying that I'm right but you don't
like me, so you don't want to talk to me, that is surely a 
grown up approach, or maybe not? Not sure about it...

To implement negative indexing, it is necessary to walk to the end of the string to count the number of occurrences, while "remembering" where each one appears, and then backtrack to the position of the Nth-from-last match and replace just that one.

Those who think this is both easy and worthwhile,

If you have written the code for the forward indexing,
it's easy and worthwhile,otherwise not so much,no?

Anyway it seems that nobody here is able to do it now,
so maybe this is the wrong place to ask for such things.

Are there other mailing list with more knowledgeable
people on this specific subject? Maybe ZSH-workers?

Messages sorted by: Reverse Date, Date, Thread, Author