keep only alphabet characters

后端 未结 5 1936
离开以前
离开以前 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

    Using a stream:

    List letters = string.chars()
        .mapToObj(i -> (char) i)
        .filter(Character::isAlphabetic)
        .collect(Collectors.toList());
    

提交回复
热议问题