in reply to regex problem

each time you run a regex, your $1, $2, $3 vars are reset. So your msg is in $1 not $2.