Hi all, this must be quite simple but I am having great difficulty. You see I am trying to find a string within another string as follows.
e = input.indexOf("-->");
s = input.indexOf("<!--");
input = input.replace(input.substring(s, e + 3), " ");
The integers e and s are returning -1 in that it was not found and this is causing the replace method to fail. The test string I am using is "Chartered Certified<!--lol--> Accountants (ACCA)"
. I tried to creat a new string object and pass in the string as an argument as follows
e=input.indexOf(new String("<!--"));
This yielded the same result. Any ideas ?
This is a stand alone piece of code I wrote and it works perfectly.
public static void main(String[] args) {
int e = 0;
int s = 0;
while (e != -1) {
//input.replace("\"", "\'");
e = input.indexOf("-->");
s = input.indexOf("<!--");
input = input.replace(input.substring(s, e + 3), " ");
e = input.indexOf("-->");
System.out.println(input);
}
}
But I cannot seem to see why it fails when i use this logic in my action class.