How to remove ALL IRC Colour codes from string
01:19 25 Mar 2015

note: I'm using Python3

I've been searching everywhere and finding nothing complete. Asking on IRC everywhere. I need a regex expression that removes ALL IRC colour control codes. Nowhere is there a complete solution.

Bold, Italics, Underline, Reverse, Colour, and Plain text The characters numbers are 2 29 31 22 3 15 respectively.

Edited:

I just found a \x0f character being used also.

The Colour character (3) contains possibly max 2 digits after it, with a possible comma then up to max of 2 digits more or no digits just character 3. It might also just be a comma with plain text after it in which case the comma should be left in the string.

Please help I am stuck in the mud.

Example:

'\003' + '12,4' + 'Red and blue' + '\003'+', \031Underline\031' 

The 12 is blue and the 4 is red, used with character 3.

The expected output is just "Red and blue, Underline" plain text, no colour codes. That way I can use:

line = 'Red and blue, Underline'

line.split(' ')[0] == 'Red'
python regex python-3.x colors irc