I am writing a program that reads text but must ignore case, spaces and punctuation while evaluating a string for palindrome. When I use the following the case issue is solved.
String str = "";
if (str.toLowerCase().charAt(LHS) != str.toLowerCase().charAt(RHS))
...but when I use the following I get IndexOutOfBoundsException error can anyone explain why?
String str = "";
if (str.toLowerCase().replaceAll("\\w", "").charAt(LHS) != str.toLowerCase().replaceAll("\\w", "").charAt(RHS))