What is encoding: <ESC> [00p <ESC> (1 * 259 * 01/26/10 * 11.05 * <CR>
I have a .txt file provided for me to parse, to pull out certain information, and I really don't want to write a scanner for this. This is similar to ANSI for me, perhaps a little more is added to it. I dont know. This is an automatic exit from some hardware that is years and years old. Here's a little more to get an idea of what I mean and how the result should look.
<ESC>[00p<ESC>(1*259*01/26/10*11.05*<CR>
<ESC>[05pEJ LOG COPIED OK 247C0200 <CR>
<FF><ESC>[05p*3094*1*R*09<CR>
<ESC>[00p<ESC>(1*260*01/26/10*11.07*<CR>
<ESC>[05pSUPERVISOR MODE EXIT <CR>
Expected Result:
*259*01/26/10*11.05*
EJ LOG COPIED OK 247C0200
*3094*1*R*09
*260*01/26/10*11.07*
SUPERVISOR MODE EXIT
As I said, this is a little on pages and pages. Maybe ANSI, I am not defined. If I missed some critical information, let me know. I am coding in C # btw. I would include the name / model of the device, but I do not know this. Thank!
- :
string input = @"
<ESC>[00p<ESC>(1*259*01/26/10*11.05*<CR>
<ESC>[05pEJ LOG COPIED OK 247C0200 <CR>
<FF><ESC>[05p*3094*1*R*09<CR>
<ESC>[00p<ESC>(1*260*01/26/10*11.07*<CR>
<ESC>[05pSUPERVISOR MODE EXIT <CR>";
foreach (Match m in Regex.Matches(input,
@"(?:(?:<FF>)?(?:<ESC>[\[\(](?:\d{2}p|\d\*))+)(?<output>.*)",
RegexOptions.Multiline))
{
Console.WriteLine(m.Groups["output"].Value);
}
:
<ESC>\x1B<FF>\xFF<CR>\x0D
ANSI Escape sequence. . ANSI.
What you are looking for is a parser that can read these code sequences. Here 's a parser written in C that claims to remove escape sequences from ANSI sequence input. Perhaps you want to try it.