Java通过substring截取指定字符

package com.shucha.deveiface.biz.test;

import com.sdy.common.utils.StringUtil;

/**
 * @author tqf
 * @Description
 * @Version 1.0
 * @since 2022-05-17 11:14
 */
public class test2 {
    public static void main(String[] args) {
        String name = "mysql_表名_ddd_2";
        System.out.println(tableNameSubString(name));
    }

    /**
     * 表名截取
     * @param tableName
     * @return
     */
    public static String tableNameSubString(String tableName){
        String name = "";
        if(StringUtil.isNotBlank(tableName)) {
            name = tableName.substring(tableName.indexOf("_")+1,
                    tableName.lastIndexOf("_"));
        }
        return name;
    }
}

截取字符为:表名_ddd 

posted @   码奴生来只知道前进~  阅读(20)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· 什么是nginx的强缓存和协商缓存
· 一文读懂知识蒸馏
· Manus爆火,是硬核还是营销?
点击右上角即可分享
微信分享提示