I read in the release notes of Bash 5.1:
p. BASH_REMATCH is no longer readonly.
As explained in the Bash Reference Manual:
The array variable BASH_REMATCH records which parts of the string matched the pattern. The element of BASH_REMATCH with index 0 contains the portion of the string matching the entire regular expression. Substrings matched by parenthesized subexpressions within the regular expression are saved in the remaining BASH_REMATCH indices. The element of BASH_REMATCH with index n is the portion of the string matching the nth parenthesized subexpression.
And yes, it is very useful to access the matches of a regular expression:
$ DESERT=pie-cake_berry_cream-sirup
$ [[ $DESERT =~ _(.*)_ ]] && echo "${BASH_REMATCH[1]}"
berry
However, I cannot see what is the use of this news in Bash 5.1. That is, what is the point of BASH_REMATCH not being readonly?