Here is an example of a message:
User: tbone Location: / Anyone Time: 23:23:23 This is a small message This is a way HTTP- and other protocols- ish: The header followed by a blank line and message body.
What is the easiest way to parse it? I like the standard if I can work a bit better than the white spot, it would be very easy for me. That is, in the header, it should ignore the white space around a colon, but let me know about the spaces between the words and the Newlines. I should also know when the message body starts.
Maybe the scanner might be the right tool for the job? Is there a better strategy? Should I just write my own small parser, which at one time does a character (or sometimes two) and builds my data structure? This is the inconvenience that I would like to save, but I can do it.
By the way, I control the message format. Is there a better message format that will simplify the job?
The text / scanner will be overhead (in programmer time) to use for this format for.
Using net / http, you may also be able to use MIMEHeader to search and.
If you need anything more complex than MIMEHeader, then I would just consider using JSON.
No comments:
Post a Comment