博客
关于我
java匹配字符串中某个字符
阅读量:204 次
发布时间:2019-02-28

本文共 465 字,大约阅读时间需要 1 分钟。

public class PatternMatchUtils {    private static final String DASH = "-2";    public static String subStringVals(final String sourceNo){        //寻找第一个破折号出现的位置        final Matcher matcher= Pattern.compile(DASH).matcher(sourceNo);        if (!matcher.find()){            return "";        }        final Integer index = matcher.start();        final String operationType = sourceNo.substring(index+1,index+5);        return operationType;    }}

匹配第一个出现的 “-”并截取后四位

转载地址:http://bqii.baihongyu.com/

你可能感兴趣的文章
MySQL数据类型
查看>>
MySQL数据类型字节长度
查看>>
mysql数据被误删的恢复方案
查看>>
MySQL数据读写分离(MaxScale)上干货!!!
查看>>
mysql整库导入、导出
查看>>
mysql文本函数和数字函数
查看>>
Mysql新建用户和数据库并授权
查看>>
mysql日志
查看>>
mysql日志 事务问题_mysql因为事务日志问题无法启动
查看>>
mysql日志文件
查看>>
mysql日志管理学习笔记
查看>>
mysql日志问题定位实用命令
查看>>
MySQL日期时间函数大全
查看>>
mysql时间相减的问题
查看>>