Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in parsing

 
Pramod P Deore
Ranch Hand
Posts: 632
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Ranchers I am parsing one string with split() method. But Output is not getting what I expected. following is my code:


I want output as :



But I got output as



Means after every line one space is added. How to get expected output? Thanks in advance

>
 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You probably want this as regex "[|$^]+"
But then there are still empty lines in your result.
 
Pramod P Deore
Ranch Hand
Posts: 632
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wouter Oet wrote:You probably want this as regex "[|$^]+"
But then there are still empty lines in your result.


Thanks Wouter for your reply. Yes you are right now I get output as


How to remove this empty line?
 
Pramod P Deore
Ranch Hand
Posts: 632
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ohh My Bad

You are right Wouter Oet. There is a blank line because string itself contains one space. Thank you very much.
 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Glad I could help.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic