The signature of String's replace method is:
>>public String replace(char oldChar, char newChar), <<
so your method call is wrong, or in other words you need to implement it by
yourself or here is little help:
public static String replace(String str, String pattern, String replace)
{
int s = 0;
int e = 0;
StringBuffer result = new StringBuffer();
while ((e = str.indexOf(pattern, s)) >= 0)
{
result.append(str.substring(s, e));
result.append(replace);
s = e+pattern.length();
}
result.append(str.substring(s));
return result.toString();
}
and you just need to call it replace(searchitems, " ", "%\'
OR \'%")
good luck!
----- Original Message -----
From: James McIntosh <james@m...>
To: Pro_JavaServer_Pages <pro_jsp@p...>
Sent: Sunday, July 01, 2001 9:39 AM
Subject: [pro_jsp] replacing character with string
> Hi,
>
> I am trying to replace a space in a string with another this:","%\' OR \'%
>
> This is what I thought of but they only let me replace one character with
> another, any suggestions?
>
> searchitems = searchitems.replace(" ","%\' OR \'%");
>
> StringBuffer buffer = new StringBuffer();
> buffer.append(searchitems);
> buffer.replace(" ","\%\' OR \'\%");
> buffer.toString();
> searchitems = buffer;
>
>
> Thanks Heaps!