Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
For instance, for a string "book", i want to make it "boxxxxok". Also if i want to replace one of the elements such as "book" to "boxk" and also delete an element such as "book" to "bok". What is the easiest method to do this?
Posted
Comments
Xiao Ling 11-Nov-14 21:05pm    
You can use StringBuffer to append characters based on your algorithm

It's easier just to do it yourself rather than wasting time asking in an online forum.
 
Share this answer
 
v2
 
Share this answer
 
There are many ways, the problem will be for you to work it out for any set of strings.

E.g:
Java
"book".replace("oo","ooxxxok");

or use substring to cut
Java
string bo="book".substring(0,2); string ok="book".substring(2,2)

then add together
Java
string s = bo.concat("xxxx").concat(ok);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900