您当前的位置: 首页 >  Java

命运之手

暂无认证

  • 1浏览

    0关注

    747博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

【Java】【正则表达式】去除字符串中的非数字字符

命运之手 发布时间:2019-10-23 10:13:56 ,浏览量:1


    //将异常的字符串转化为整数
    public static Integer abnormalTextToInt(String text, Integer defaultValue) {
        try {
            return Integer.parseInt(Pattern.compile("[^0-9]").matcher(text).replaceAll("").trim());
        } catch (Exception e) {
            return defaultValue;
        }
    }

关注
打赏
1654938663
查看更多评论
立即登录/注册

微信扫码登录

0.0424s