How can I remove punctuation from input text in Java?

后端 未结 5 1185

I am trying to get a sentence using input from the user in Java, and i need to make it lowercase and remove all punctuation. Here is my code:

    String[] wo         


        
5条回答
  •  广开言路
    2020-12-02 07:38

    You can use following regular expression construct

    Punctuation: One of !"#$%&'()*+,-./:;<=>?@[]^_`{|}~

    inputString.replaceAll("\\p{Punct}", "");
    

提交回复
热议问题