dcsimg
Please tell me how can i replace symbol '!_CARRIAGERETURN_!' (Enter,...
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Alexander_K
Posted On:   Monday, February 26, 2001 03:07 AM

Please tell me how can i replace symbol '
' (Enter, 13) by another symbol for example _blank_ (' ') . It's ('
') placed into string not in begin and end. I try use String.replace('
', ' '); but dosn'e recieve desireable result. What i must do? Thank You.

Re: Please tell me how can i replace symbol '!_CARRIAGERETURN_!' (Enter,...

Posted By:   Adrian_Mitrica  
Posted On:   Thursday, November 8, 2001 08:09 AM

You can use something like:



String theString = "whatever string";
theString = myReplace(theString, '
', "
");



where myReplace is:



private String myReplace(String inWhatToReplace, char whatToReplace, String withWhatToReplace){
int theIndex = 0;
String allReplaced;
StringBuffer repl = new StringBuffer();
theIndex = inWhatToReplace.indexOf(whatToReplace,0);
while(theIndex > 0){
repl.append(inWhatToReplace.substring(0, theIndex));
repl.append(withWhatToReplace);
inWhatToReplace = inWhatToReplace.substring(theIndex + 1);
theIndex = inWhatToReplace.indexOf(whatToReplace,0);
}
repl.append(inWhatToReplace);
allReplaced = repl.toString();
return allReplaced;
}
About | Sitemap | Contact