tony_in_da_uk@yahoo.co.uk Guest
|
Posted: Wed Aug 17, 2005 5:27 pm Post subject: Re: ANSI escapes in text |
|
|
I think the lack of response here is largely due to the lack of detail
in your query. Do you want to throw away such sequences, or extract
their parameters for processing? Do you just want the sequences you'd
find supported by MS-DOS ansi.sys? I don't personally know (or care -
sorry)whether the ANSI publishes standards for vt100, vt220 or other
protocols. Anyway, ansi.sys-type escape sequences are so few that
parsing them is trivial, especially if you don't care about the more
obscure ones embedding double-quotes strings.
You could create your own regexp expression in a few minutes, but again
it will vary depending on whether you need to select and return the
parameter subexpressions, and the exact syntax your regexp library
provides for doing so. You could equally use boost::spirit or write
something from scratch. If you end up doing the latter, I'd suggest
when you find an escape, scan forward until you find an alphabetic
character, while skipping over any double-quoted strings. You can then
use the final character to go back and extract the arguments, perhaps
switching on that final character to select a sscanf() format string
matching the possible parameters. Easier still, but slower, ditch the
`scan forward to find the final character' business and code the whole
thing as an if/else list of sscanf()s.
Tony
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|