Palindrome machine using recursion and regex