There really isn't any need to use regex here unless you might have some other format for [AFK]. Otherwise, just use this:
alias afk {
if ([AFK] !isin $me) { nick [AFK] $+ $me }
}
alias back {
if ([AFK] isin $me) { nick $remove($me,[AFK]) }
}
One of the main reasons your regex isn't working is that []'s are special characters. To include them in a match, you need to escape them using \ . For example /
\[AFK
\]/ . Or, in the regex... $regex($me,/\[AFK\]/)
Technically, you probably don't need the \ before the ], but it is required before the [ and it's a good idea to also include in before the ] even if it doesn't change the output.