On Mon, 2 Feb 2026, Greg Wooledge wrote: > On Mon, Feb 02, 2026 at 17:18:57 +0000, [email protected] wrote: >> why bash only, just because > > "Because every real language has a sensible way to do this, so there's > no challenge." I'm guessing. > >> i found this solution that works >> BUT, would one/some of you big brained folks elaborate > > Elaborate on what? > >> string="wonkabars" >> [[ "$string" =~ ${string//?/(.)} ]] # splits into array >> printf "%s\n" "${BASH_REMATCH[@]:1}" # loop free: reuse fmtstr >> declare -a arr=( "${BASH_REMATCH[@]:1}" ) # copy array for later > >> The above will work with strings containing newlines, > > Indeed, it seems to. Unfortunately, your sample code uses a string > containing only letters, instead of a more interesting input. > > hobbit:~$ string=$'abc \t\n\n\'"\\' > hobbit:~$ [[ $string =~ ${string//?/(.)} ]] > hobbit:~$ declare -p BASH_REMATCH > declare -a BASH_REMATCH=([0]=$'abc \t\n\n\'"\\' [1]="a" [2]="b" [3]="c" [4]=" > " [5]=$'\t' [6]=$'\n' [7]=$'\n' [8]="'" [9]="\"" [10]="\\") >
that is more interesting i'll chew on that for a bit

