Re: Parsing colorcodes
| From: | Burhan Khalid | Date: | Sun, 26 Oct 2003 19:20:35 +0000 |
| Subject: | Re: Parsing colorcodes | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-167640@lists.php.net to get a copy of this message | ||
Simon Fredriksson wrote:
Hiya fellow PHP coders! I have a problem. I need a function to parse mIRC-colorcodes with PHP. Unfortunaly, I'm not capable to do this myself (or I'm thinking too advanced or something). The code is built like this; chr(3) starts the color formating. After that sign, a series of numbers will come. Can be one or two digits (1-15). 0-9 can have an additional zero before it, like 00-09. Each of these number represents a color.[ snip ]
Now, to make it even worse, it's possible to use a background-color for the text. This is added with a coma. So, the syntax is "X4,8String" where X is really chr(3). Red (4) String with yellow (8) background.I'm not a regex guru, but |[0-9]{2},[0-9]{2}(*.?)| should capture it. I forget how to ask the regex for optional items, but that should get you started. -- Burhan Khalid phplist[at]meidomus[dot]com http://www.meidomus.com