replace与replaceAll替换字符

public void testString(){
        String str="wel2come3Souhe0";
        System.out.println(str.replace("e","E"));
        System.out.println(str.replace('e','E'));
        System.out.println(str.replaceAll("\\d","A"));
        System.out.println(str.replaceAll("3","9"));
    }

结果:

wEl2comE3SouhE0
wEl2comE3SouhE0
welAcomeASouheA
wel2come9Souhe0

posted on 2019-02-21 10:23  城市小农民  阅读(147)  评论(0编辑  收藏  举报

导航