The regular expression is "\[[~\]]*\]" which means:
look for a bracket "\[" (\ is the escape char)
followed by a string not containing a closing bracket "[~\]]*"
followed by a closing bracket "\]". The match string include the brackets
You can also read "Scan from String" with the following format: "%[^\[]\[%[^\[\]]" and read the 2nd output. The brackets are removed from the scanned string.