Java special characters

Posted by Binaryrespawn on Stack Overflow See other posts from Stack Overflow or by Binaryrespawn
Published on 2010-03-31T17:37:43Z Indexed on 2010/03/31 17:43 UTC
Read the original article Hit count: 316

Filed under:

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 ?

© Stack Overflow or respective owner

Related posts about java