StringUtils 工具

		<dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
        </dependency>

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
实验室:
常用方法:

        StringUtils.truncate("abcdefg", 7);
        StringUtils.wrapIfMissing("ab", 'x');
        StringUtils.remove("queued", "ue");
        StringUtils.replace("aba", "a", "");
        StringUtils.lastIndexOf("sdfafvdsffs", "v");
        StringUtils.appendIfMissing("sdsf","dfsf");
        StringUtils.substring("abc", 2);
        StringUtils.overlay("abcdef", "zzzz", -1, 4);
        StringUtils.equals("abc", "ABC");

全量的:

        String abl = "1,2,3,4,5,6";        // 11
        String abStr = "axcvabnmlKjhduweiu";// 17
        String abLagu = "犯我中华者";
        String abln = "\n";
        // abbreviate = ax...
        System.out.println("abbreviate = " + StringUtils.abbreviate(abStr,5));
        //  abbreviate2 = ...nmlk...
        System.out.println("abbreviate2 = " + StringUtils.abbreviate(abStr,5,10));
        //  abbreviate3 = axcvbnm***
        System.out.println("abbreviate3 = " + StringUtils.abbreviate(abStr, "***", 2, 10));
        // 中间替换符    abbreviateMiddle = axc***eiu
        System.out.println("abbreviateMiddle = " + StringUtils.abbreviateMiddle(abStr, "***", 9));
        // 字符串尾部加指定字符   appendIfMissingIgnoreCase() = axcvbnmlkjhduweiuk
        System.out.println("appendIfMissingIgnoreCase() = " + StringUtils.appendIfMissingIgnoreCase(abStr,"k"));
        //  appendIfMissing = 1,2,3,4,5,6,7
        System.out.println("appendIfMissing = " + StringUtils.appendIfMissing(abl,",7","5"));
        // appendIfMissing = 犯我中华者,虽远必诛
        System.out.println("appendIfMissing = " + StringUtils.appendIfMissing(abLagu,",虽远必诛","华"));
        //  appendIfMissingIgnoreCase = 犯我中华者,虽远必诛
        System.out.println("appendIfMissingIgnoreCase = " + StringUtils.appendIfMissingIgnoreCase(abLagu, ",虽远必诛", "华"));
        // 首字母达成大写
        System.out.println("capitalize = " + StringUtils.capitalize(abStr));
        // center =   犯我中华者
        System.out.println("center = " + StringUtils.center(abLagu,10));
        //  center = axcvbnmlkjhduweiu
        System.out.println("center = " + StringUtils
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值