Query label_replace function

label_replace(
(global_peers_details),
“peers_1”,
"$1[$1] & $2[$2] ",
“peers_1”,
“(.),(.)”
)
I have 3 nodes cluster. so The metric will shows the current node where it connects with other two nodes through label peers_1.
when I ran above Prom Query, I get the label peers_1="BB903[BB903] & BB904[BB904] " as a output which is other two nodes node_id.
In the query, I given “$1[$1] & $2[$2]” and “(.),(.)” Because I had only two nodes which replace “,” to “&”.
Now how can I modify the query like $1[$1} to $32[$32} if I had 32 nodes. Instead of updating manually like "$1[$1] & $2[$2} & $3{$3} & $4[$4] & $5[$5} & $6[$6] etc until $32[$32} and (.),(.),(.),(.) for 32 times . Give a static solution without manual updating for $1, $2 to $32 for each nodes.