[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to substitute in a string for the first n matches?
From: |
arnold |
Subject: |
Re: How to substitute in a string for the first n matches? |
Date: |
Mon, 29 Mar 2021 00:33:56 -0600 |
User-agent: |
Heirloom mailx 12.5 7/5/10 |
This is the right idea. For production use it should be
wrapped in a nice function.
Arnold
david kerns <david.t.kerns@gmail.com> wrote:
> don't hate me!
>
> awk -v n=4 'BEGIN{x="rrrrrrrrrr";for(i=0;i<n;i++){sub("r","x",x)}print x}'
>
> On Fri, Mar 26, 2021 at 1:57 PM Peng Yu <pengyu.ut@gmail.com> wrote:
>
> > Hi,
> >
> > man gawk says.
> >
> > """
> > gensub(r, s, h [, t])
> >
> > h is a number indicating which match of r to replace.
> > """
> >
> > Is there a way to perform string substitution for the first n matches in
> > awk?
> >
> > --
> > Regards,
> > Peng
> >
> >
- How to substitute in a string for the first n matches?, Peng Yu, 2021/03/26
- Re: How to substitute in a string for the first n matches?, david kerns, 2021/03/26
- Re: How to substitute in a string for the first n matches?,
arnold <=
- Re: How to substitute in a string for the first n matches?, arnold, 2021/03/29
- Re: How to substitute in a string for the first n matches?, Wolfgang Laun, 2021/03/29
- Re: How to substitute in a string for the first n matches?, Peng Yu, 2021/03/29
- Re: How to substitute in a string for the first n matches?, Wolfgang Laun, 2021/03/29
- Re: How to substitute in a string for the first n matches?, arnold, 2021/03/29
- Message not available
- Message not available
- Message not available
- Message not available
- Re: How to substitute in a string for the first n matches?, Denis Shirokov, 2021/03/31