This week's book giveaway is in the JDBC forum.
We're giving away four copies of Make it so: Java DB Connections & Transactions and have Marcho Behler on-line!
See this thread for details.
The moose likes Servlets and the fly likes Please help me Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Please help me" Watch "Please help me" New topic

Please help me

Garry Kalra
Ranch Hand

Joined: May 25, 2001
Posts: 111
Please tell me how to do this. I've got a String named schoolName as
String schoolName = "[School][Category][Type]";
I want to convert all those [ in the string to [= and all
tose ] to +]. Please tell me if there is a function to do so. I
understand that i can do so by scanning through the String, but i
need a function that replaces a single character with a string.
Hope i have made myself clear, if not still, please tell me.
Gaurav Kalra
k b

Joined: Feb 01, 2001
Posts: 22
// Here is a method that can help your problem

private String replaceText(String orig, char c, String s){
String modified =orig;
while(orig.indexOf(c) != -1){
int index = orig.indexOf(c);
modified = orig.substring(0,index) + s + orig.substring(index+1);
orig = modified;
return modified;
I agree. Here's the link:
subject: Please help me
It's not a secret anymore!