code:
function OnEvent_ChatWndSendMessage(Wnd,Msg){
...
Msg = Msg.replace(/\(\!MEH\)/g,variable);//replace (!MEH) with string in variable
..
}
If you want it to be case insensitive then use gi rather than just g. This just uses regular expressions, which I highly recommend for all scripters to learn.