I did something like this with my Message Converter script if you have a look. It isn't the easiest of things but here is an extract of what I did.
code:
[...]
var bb = /\[b\]/gi;
var eb = /\[\/b\]/gi;
[...]
function OnEvent_ChatWndSendMessage(ChatWnd,Message){
while ((arr = eb.exec(Message)) != null){
var prev = RegExp.leftContext;
var MessageEnd = RegExp.rightContext;
Inner3:
while ((arr1 = bb.exec(prev)) != null){
var extract = RegExp.rightContext;
var MessageBeg = RegExp.leftContext;
if (eb.exec(extract)!=null){
prev = MessageBeg;
while(bb.exec(prev)!=null){
}
continue Inner3;
}
}
Message = MessageBeg+""+extract+""+MessageEnd;
while(eb.exec(Message)!=null){
}
continue Outer3;
}
[...]
return Message;
}
There are probably some better ways of going about some of the things but I know this works as a starting point. This extract just finds the last instance of [/b] and finds the corresponding [b ]
and will exclude any full [b ]...[/ b] in the middle(
EDIT: relised it didn't so this, only the colour and background parts did as the likes of bolding doesn't need to be, though i should really check for any and make them not do anything rather than add 2 pointless characters) and replaces the beginning and end with the bold and ending of the bold for IRC style. I hope this helps and if you need any help understanding my code then you can add me the WLM.
EDIT2: as I look over the code again, I probably don't need the continues in there as it should do the same thing with or without them there. Sorry for the edits btw.
* markee writes a mental note about his dodgy scripting ability