Palindrome tester with Java, ignoring spaces and punctuation

后端 未结 7 1409
忘了有多久
忘了有多久 2021-01-07 04:26

I have the program made up until the point where it has to ignore and punctuations and spaces in the thread and I was wondering if anyone could help me with the coding for t

7条回答
  •  清歌不尽
    2021-01-07 04:48

    You could simplify the code significantly by removing all the spaces and punctuation before you start. Look at String.replaceAll(regex,replacement). You would write a regular expression to match blanks and punctuation, and provide an empty string ("") as the replacement. This will return a new string containing the original minus the characters you want to ignore.

提交回复
热议问题