[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: String to array
From: |
Tapani Tarvainen |
Subject: |
Re: String to array |
Date: |
Thu, 30 Sep 2021 17:25:35 +0300 |
On Thu, Sep 30, 2021 at 09:48:13AM -0400, Greg Wooledge (greg@wooledge.org)
wrote:
> As I understand it, you're asking for "no explicit loops", and "no
> forked processes".
Yes (although I'd be interested in pretty solutions with forked
processes, too).
> Are implicit loops allowed? I mean, they *must* be, right? There's
> no way to do this without a loop being involved in *some* underlying
> layer, hidden away in the bowels of the shell.
Of course.
> unicorn:~$ n=${#string}; eval "printf -v re '(.)%.0s' {1..$n}"
> unicorn:~$ [[ $string =~ $re ]] && declare -p BASH_REMATCH
That is clever!
And beats my hack by having just one eval, too. :-)
--
Tapani Tarvainen
- String to array, Tapani Tarvainen, 2021/09/30
- Re: String to array, Leonid Isaev (ifax), 2021/09/30
- Re: String to array, Alex fxmbsw7 Ratchev, 2021/09/30
- Re: String to array, Greg Wooledge, 2021/09/30
- Re: String to array,
Tapani Tarvainen <=
- Re: String to array, Greg Wooledge, 2021/09/30
- Re: String to array, Greg Wooledge, 2021/09/30
- Re: String to array, Alex fxmbsw7 Ratchev, 2021/09/30
- Re: String to array, Greg Wooledge, 2021/09/30
- Re: String to array, Alex fxmbsw7 Ratchev, 2021/09/30