| Author |
Drop part of a line
|
E Jen
Greenhorn
Joined: Oct 22, 2006
Posts: 5
|
|
I have some code written to read a chatlog file, one that you may find from an IM system. Most of the lines that are read look like this: [10:34:46] MESSAGE HERE How would I get it to drop the time stamp? The code I have currently written is: [ October 22, 2006: Message edited by: E Jen ]
|
 |
Jim Yingst
Wanderer
Sheriff
Joined: Jan 30, 2000
Posts: 18670
|
|
OK, this is weird. I see you have used code tags - good, thank you very much. And yet your code still seems to have almost no indentation. What's up? Do you not find it useful to indent your code to make it readable? I find it difficult to motivate myself to bother reading something if the author hasn't put at least a little effort into making it readable. Note that you can edit your post using the little icon at the top of the post. Thanks.
|
"I'm not back." - Bill Harding, Twister
|
 |
Scott Johnson
Ranch Hand
Joined: Aug 24, 2005
Posts: 518
|
|
Use the methods available on the String object such as indexOf() and substring(). Or you can use regular expression to grab all of the characters after the sequence "] ".
|
 |
Ken Blair
Ranch Hand
Joined: Jul 15, 2003
Posts: 1078
|
|
|
Considering the fact that in my experience in such a log file every single line is one message and the format is a strict [hh:mm:ss] where 9 is "09" it could be as simple as using String.substring(10) to get everything after the time stamp and the space which are a fixed size.
|
 |
E Jen
Greenhorn
Joined: Oct 22, 2006
Posts: 5
|
|
Originally posted by Jim Yingst: OK, this is weird. I see you have used code tags - good, thank you very much. And yet your code still seems to have almost no indentation. What's up? Do you not find it useful to indent your code to make it readable? I find it difficult to motivate myself to bother reading something if the author hasn't put at least a little effort into making it readable. Note that you can edit your post using the little ![]() icon at the top of the post. Thanks.
Sorry about that. Normally it is indented when I right it, somehow I messed that up. And thank you for all of your replies.
|
 |
 |
|
|
subject: Drop part of a line
|
|
|