• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 480
  • Last Modified:

Parsing irc raw data

Hello, what would be the feasible way to parse the raw IRC data given below?

:singapore.sg.galaxynet.org 372 Google123 :- *☻!☻* *☻!☻*]
:singapore.sg.galaxynet.org 376 Google123 :End of /MOTD command.
:singapore.sg.galaxynet.org NOTICE Google123 :*** Notice -- This server runs an
open proxy monitor to prevent abuse.
:singapore.sg.galaxynet.org NOTICE Google123 :*** Notice -- If you see connectio
ns on various ports from irc.maxonline.com.sg
:singapore.sg.galaxynet.org NOTICE Google123 :*** Notice -- please disregard the
m, as they are the monitor in action.
:singapore.sg.galaxynet.org NOTICE Google123 :*** Notice -- For more information
 please visit http://www.galaxynet.org/proxy.php
:singapore.sg.galaxynet.org NOTICE Google123 :on 1 ca 1(2) ft 10(10) tr
:Q!chanserv@galaxynet.org PRIVMSG Google123 :☺VERSION☺
:Q!chanserv@galaxynet.org NOTICE Google123 :Type "/msg Q news" for the latest GalaxyNet news! (updated 14/9/2004 11:19)

  • 2
  • 2
1 Solution
certainly :)

looks like splitting on : would be a good start

String[] tokens = line.split(":");
Then parse each field as required
dr0zaxxAuthor Commented:
spliting on : would be dangerous right? let's say a user post something in his message that contains ":" ..

wrong info would be parsed.
Perhaps, it would depend on the exact details of format.
Perhaps all you need is the uindex of the first two :'s and treat everything after the second as text, something like:

int first = line.indexOf(':');
int second = line.indexOf(':', first+1);
String details = line.substring(first+1, second-1);
String[] parts = details.split(" ");

dr0zaxxAuthor Commented:
Ok, thanks for your help anyway, based on your first answer, i managed to figure out a solution myself..

using StringTokenizer and split together. thanks

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now