Hi,
I hate regex and I'm a noob with it...
In a websock-telnet app I receive data from client.
The data can containing ansi-color escape sequences, BUT not always the escape data come complete. Sometimes the escape-sequence is truncated.
For ex.
Before I recive "\e[" and only after I recive "0;37m".
I need to find a regex that can handle when the ending of data arrival contain a incomplete ansi-escape sequence.
Avaible sequences that I founded are: http://bluesock.org/~willg/dev/ansi.html#sequences
My try:
if ( preg_match("/^[0-9;\e[]+$/", substr($data, -1) ) == 1 )
{
/* if the last $data char is a number
or a ";"
or a "\e"
or a "["
so it's possible that ending data contain a truncated ansi color sequence.
*/
}
Can someone help me to build a better regex to handle chunked escape data? (with comments if possible).
Thank you in advance
math