What is the zsh equivalent for $BASH_REMATCH[]?
问题 What is the equivalent in zsh for $BASH_REMATCH , and how is it used? 回答1: To make zsh behave the same as bash , use: setopt BASH_REMATCH Or within a function consider: setopt local_options BASH_REMATCH (this will only set the option within the scope of the function) Then just use $BASH_REMATCH as you would in bash . The manual says about BASH_REMATCH : When set, matches performed with the =~ operator will set the BASH_REMATCH array variable, instead of the default MATCH and match variables.