Java 1.3 does not have replaceAll() unfortunately.
Main Topics
Browse All TopicsI need to come up with a good way to search through a string and replaceAll certain characters with another string.
If the string contains either of the following: & ' "
I need to replace all & with "and" and replace all single/double quote with "quote".
In my code below, how do I modify it so it searches for either of the 3 characters, without looping 3 times, one for each char.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
sorry didn't notice you were using 1.3.
why is looping a problem? You're already looping (for each instance of the string), so looping for all possibles strings seems ok. In fact it would seem the cleanest
for (int=0; i<patterns.length; i++) {
String pattern = patterns[i];
int found = -1;
int start = 0;
while( (found = source.indexOf(pattern, start) ) != -1) {
sb.append(source.substring
sb.append(replace);
start = found + len;
}
sb.append(source.substring
}
Business Accounts
Answer for Membership
by: objectsPosted on 2009-04-06 at 15:19:00ID: 24082227
easier to use replaceAll(), why not use that