in reply to Re^2: Parsing using m//gin thread Parsing using m//g
Simply change /.../xmsg to /.../xsg. and/or Simply change $ to \z.
Update: Added the second (and better) option.