So far I’ve been using ^[a-zA-Z]+( [a-zA-z]+)*$ to make sure user input Has no space in the beginning and the end and not to accept numbers or special characters and only to accept alphabetical characters.
I looked at the regex list online and in my texts I can’t seem to formulate one under these conditions for a recursive palindrome program:
- Accepts strings containing upper case or lower case characters.
- Accepts punctuation, and single spaced blanks.
I don’t think I’ll need a regex for the following after validation, but if there is I’d like to know what it is.
- After validation upper case letters must be converted to lower case.
- The punctuation and spaces are to be ignored.
If I understand you correctly, you want to create a recursive palindrome checker that employs regular expressions, in Java. I’m interested in learning Java, so I gave it a shot as my own sort of “homework problem,” although it is probably yours too.
The output is: