Java, Check if a String is a palindrome. Case insensitive

Use this regex to remove all punctuation and spaces and convert it to lower case

String palindrome = "..." // from elsewhere
boolean isPalindrome = palindrome.replaceAll("[^A-Za-z]", "").toLowerCase().equals(new StringBuilder(palindrome.replaceAll("[^A-Za-z]", "").toLowerCase()).reverse().toString());

Try this ..

public static void main(String[] args) {

    boolean notPalindrome = false;
    String string = "Doc, note, I dissent. A fast never prevents a fatness. I diet on cod";

    string = string.replaceAll("[^a-zA-Z]+","").toLowerCase();

    char[] array = string.toCharArray();
    for(int i=0, j=array.length-1; i<j; i++, j--) {
        if(array[i] != array[j]) {
            notPalindrome = true;
            break;
        }
    }
    System.out.println(string + " is palindrome? " + !notPalindrome);
}