Search code examples
c#regexreplaceircmirc

Regex Replace of Mirc Colour Codes


I am making a small / simple IRC client, for a special use case. I would like to strip out the Mirc colour codes other users are typing from their Mirc / other similar clients.

Screenshot :

enter image description here

I have been trying for approx 1hr without success :

string msg = string.Format("{0}\n", e.Data.Message);
//msg = Regex.Replace(msg, @"\x03(?:\d{1,2}(?:,\d{1,2})?)?", string.Empty); // Ive tried all sorts here.
txtActivity.AppendText(msg);

Please help, thanks in advance.

EDIT:

this is HelloWorld in red.

3
51
72
101
108
108
111
87
111
114
108
100
10

EDIT 2:

enter image description here

EDIT 3:

3
48
49
44
49
53
32
49
46
32
73
110
32
116
104
101
32
78
97
109
101
32
111
102
32
31
65
108
108
97
104
31
44
32
116
104
101
32
77
111
115
116
32
66
101
110
101
102
105
99
101
110
116
44
32
116
104
101
32
77
111
115
116
32
31
77
101
114
99
105
102
117
108
31
46
32
3
10

Solution

  • If you want to strip out ALL BURC codes (bold, underline, reverse and colour), you can also use a regular expression such as the following:

    msg = Regex.Replace(msg, @"[\x02\x1F\x0F\x16]|\x03(\d\d?(,\d\d?)?)?", String.Empty);