#!/usr/local/bin/zsh-5.3.1 typeset -A ZUI ZUI[PLUS]="X" ZUI[COLOR_END]="Z" button1='this module Gon-the-flyZ, DwithoutZ list restart' # not working button2='this module GontheflyZ, DwithoutZ list restart' # working local -A colormap colormap=( "" "" ) translate_color_marks() { # Working #disp_list=( "${disp_list[@]//(#b)([A-G])(${ZUI[PLUS]}([H-I])|)([^H-I${ZUI[COLOR_END]}]#)${ZUI[COLOR_END]}/${colormap[${match[1]}]}${colormap[${match[3]}]}$match[4]$RESET}" ) # Not working disp_list=( "${disp_list[@]//(#b)([A-G])(${ZUI[PLUS]}([H-I])|)([^${ZUI[COLOR_END]}H-I]#)${ZUI[COLOR_END]}/${colormap[${match[1]}]}${colormap[${match[3]}]}$match[4]$RESET}" ) } disp_list=( "$button1" "$button2" ) translate_color_marks print -rl -- "${disp_list[@]}" "---" >> ~/result.txt