• Post Reply Bookmark Topic Watch Topic
  • New Topic

delete and insert chars inside a along string  RSS feed

 
mythily prakash
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
Pls tell me how to remove or delete chars and include chars in a string and also i have to replace the spaces into some other thing.I know to use the "replace()" to replace chars.
Consider i have a very big string with some 6/7 lines[450 chars].I have to include a text in the first three line.then remove all the lines except the last one and also replace all blank spaces into new line.

Thanks in Advance,
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This smells like a homework, doesn't it
Look at the API for the String class. You'll find (and learn) anything you need.
 
Koh Khai Huat
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Sorry but i dun quite get what u mean could u explain more on what you are doing and how u going to let the user or your self to edit that few lines

regards
KKH
 
Ken Blair
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That should be



well it's a start anyway.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You forgot
 
mythily prakash
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi frnd,

U just forget it.I got the way to do it.U pls tell me how i should remove the non alphabetic charactes from the file i'm reading.

c my code:


and my o/p is:


the file cmd.doc has a very lengthy line of string[450 chars in 5 lines]..
Pls tell me how to remove these unwanted things.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could try using String.replaceAll and regular expressions.
With something like replaceAll("[^a-zA-Z0-9]", "");
This will keep only alphabetical characters and numbers.
Just set all the characters you want to keep into the brackets.

For details about regular expressions, see the replaceAll API.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!