keep only alphabet characters

后端 未结 5 1929
离开以前
离开以前 2021-02-06 22:34

What method should I follow in java to produce

\"WordWord\"

from

\"Word#$#$% Word 1234\"
5条回答
  •  有刺的猬
    2021-02-06 23:29

    public static void main(String[] args) {
        String input = "Word#$#$% Word 1234";
        String extract = input.replaceAll("[^a-zA-Z]+", "");
        System.out.println(extract);
    }
    

    output:

    WordWord
    

提交回复
热议问题