[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: |
Wolfgang Laun |
Subject: |
Re: How to substitute in a string for the first n matches? |
Date: |
Mon, 29 Mar 2021 16:52:05 +0200 |
Peng,
if you have a task that requires the frequent handling of long string with
functions like these, (g)awk may or may not be the right tool.
(g)awk hides implementation details - as I said, you don't see the storage.
Hence, it is useless to think in terms of string copying if you see a
statement like
stra = strb strc
First, the implementation doesn't need to store these strings in the C
manner, i.e. bytes followed by a zero byte. The second reason is that - if
string copying is used - it'll happen in a way that makes a string copy
almost like a single instruction, running the actual loop in microcode.
-W
On Mon, 29 Mar 2021 at 16:44, Peng Yu <pengyu.ut@gmail.com> wrote:
> On Mon, Mar 29, 2021 at 9:38 AM <arnold@skeeve.com> wrote:
> >
> > Unless your string is many megabytes long, you won't notice the time
> > issue.
>
> I don't want to assume how small the input is.
>
> > There are other options, for example using patsplit and then putting
> > the string back together as desired.
>
> This incurs extra copying.
>
> > In any case, gensub isn't going to be extended to allow arbitrary
> > ranges and/or lists of occurrences to substitute.
>
> Why it can not be extended? After all, the extension won't break any
> existing function call convention.
>
> > Gawk provides
> > the basic building blocks as built-in functionality; more specific
> > use cases should be dealt with in user defined functions.
>
> The problem is that no current functionality in awk support efficient
> implementation of this feature.
>
> --
> Regards,
> Peng
>
>
--
Wolfgang Laun
- 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, 2021/03/29
- 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 <=
- 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