Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Beginning Java and the fly likes How to retrieve the number of used “/n” Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to retrieve the number of used “/n”" Watch "How to retrieve the number of used “/n”" New topic
Author

How to retrieve the number of used “/n”

chen young
Ranch Hand

Joined: Sep 09, 2005
Posts: 197
Hi,

Is there a way to retrieve the number of used “/n” in a string?
For example if I have the following string:

--------------------------------------------- START SCAN server.log.1 ---------------------------------------------

2009-01-20 09:48:35,667 [kit]DEBUG

The original was like this: --------------------------------------------- START SCAN server.log.1 ---------------------------------------------+“\n”+2009-01-20 09:48:35,667 [kit]DEBUG+”\n”

Used “\n” = 2

Thanks
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
use string.split with the -1 parameter
chen young
Ranch Hand

Joined: Sep 09, 2005
Posts: 197
thanks
 
 
subject: How to retrieve the number of used “/n”
 
jQuery in Action, 3rd edition