Inside a for loop (i) I have to test:
if [[ "${PARAMETER[$i]}" =~ $(printf "|^%s\$" "${COMMANDS[@]" | cut -c 2-)]]; then....
And my doubt is in the printf part. Sorry if it is not well explained.
The POSIX printf function works almost like its C counterpart. Here, the %s is replaced with whatever "${COMMANDS[@]" expands to. The result has a |^ prepended, and a $ appended.
If "${COMMANDS[@]" expands to multiple tokens, the result is the concatenation of all such strings.
Note: did you forget a blank before the ]]?
printfpart separately in a shell to see what it does. What part do you have doubts about?