[Irc4j-developers] parse a string
Status: Planning
Brought to you by:
maartenc
From: <car...@we...> - 2001-12-22 12:55:51
|
Hi all! I've thought about a small parser for IRC commands, but there is a little problem: I created a class "IrcCommand" with a method "parseCommand()". In "parseCommand()" I want to split the server responses like ":Nick!ho...@do... PRIVMSG MyNick :This is a message" into the prefix "Nick!ho...@do... PRIVMSG MyNick" and the message "This is a message". I thought it would be ok if I split this line with a StringTokenizer using a ':' as delimiters. But I failed immediatly at the MOTD response, because the server sends a line with the time after registering. And the time format is "HH:MM:SS". So my StringTokenizer thought, he had to split the line there... After that I tried to split the line with another algorithm: I go trough the line until a ':' is found. After that I check, if the char at the previous position is a ' ' and if that's true, I split the line here with substring(), creating two strings (prefix and message). That should work, and in the message part of the line there can be more ':', because I just don't check for ':' there. Is this right? Or can there be more ':' than the delimiter between prefix and message?? I'm working on the HTML, too. But it's very hard to create some pages without any info (like diagrams) or existing sources. So I'll just create an index page, a news page, a page with my sources and a download page for IRC RFCs. that's all for now Carsten -- car...@we... http://australien.home.pages.de/ |