String - replace substring
Posted on 1999-11-12
How can one replace part of a string with another string?
e.g. Given a string "aaaaabbbbbbccccccdddddd", replace the "bbbbb" with "zzzzz" to make the string "aaaaazzzzzcccccddddd"
You can start with:
int i = fooStringl.indexOf ("bbbbb");
but then using replace() to replace one character at a time is inefficient.
Converting it to StringBuffer doesn't seem to help, either.
There is insert(), but that's not quite it