• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

delete and insert chars inside a along string

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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,
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That should be



well it's a start anyway.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You forgot
 
mythily prakash
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Well behaved women rarely make history - Eleanor Roosevelt. tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic