I have made this replace function:
public String replace(String instr, String str1, String str2 ){
String outstr;
StringBuffer strB = new StringBuffer();
StringTokenizer strT = new StringTokenizer(instr, str1, false);
while(strT.hasMoreTokens())
{
strB.append(strT.nextToken()).append(str2);
}
return strB.toString();
}
The function work fine replacing CR with <br>. I would also use the function to replace whitespace with %20. I have tried to call the function with:
myHTML=replace(myHTML," ","%20"
;
The problem is that when i try to replace multiple whitespaces, they are onlye replaced with one %20.
Like "test *" is convert to "test%20*", i would it to be convert to "test%20%20%20%20%20%20*".
Anybody that know how i can do this?
Petal,Norway
public String replace(String instr, String str1, String str2 ){
String outstr;
StringBuffer strB = new StringBuffer();
StringTokenizer strT = new StringTokenizer(instr, str1, false);
while(strT.hasMoreTokens())
{
strB.append(strT.nextToken()).append(str2);
}
return strB.toString();
}
The function work fine replacing CR with <br>. I would also use the function to replace whitespace with %20. I have tried to call the function with:
myHTML=replace(myHTML," ","%20"
The problem is that when i try to replace multiple whitespaces, they are onlye replaced with one %20.
Like "test *" is convert to "test%20*", i would it to be convert to "test%20%20%20%20%20%20*".
Anybody that know how i can do this?
Petal,Norway