a=(NA East West) read s ${s/OOO*/+1} echo ${a[${_/XXX*/-1}]}