permaculture playing cards*
The moose likes Java in General and the fly likes replace 1 char. by 2 char. in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "replace 1 char. by 2 char. in java" Watch "replace 1 char. by 2 char. in java" New topic
Author

replace 1 char. by 2 char. in java

satyaonline
Greenhorn

Joined: Aug 23, 2001
Posts: 2
Dear Friends,
i want to pass '(apostrophy) character to the database hence,i use following code,
String mystr="let's find out what's going on";
char c='\'';
char c1='\\'+'\'';
mystr=mystr.replace(c,c1);
but above code had one problem since one character can be replaced by only one character,how can i replace in above ' by \' in above string.
Thanking you,
Hiteshonline.(satya)
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Please read our user name policy and re-register with a valid name. Thank you.
[This message has been edited by Jim Yingst (edited August 23, 2001).]


"I'm not back." - Bill Harding, Twister
David Weitzman
Ranch Hand

Joined: Jul 27, 2001
Posts: 1365

[This message has been edited by David Garland (edited August 23, 2001).]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: replace 1 char. by 2 char. in java