The
g means to search the whole string and the
i searches case-insensitively (so that FrEd still matches). The
\U just uppercases everything (in this case $1). As for the $1 and join,
data64 pretty much has it covered.
Update: zengargoyle has also done a good (and probably better) job of explaining it piece by piece.