博客
关于我
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-统计所有会员的最高前10次的积分和
查看>>
mysql会对联合索性排序优化_MySQL索引优化实战
查看>>
MySQL作为服务端的配置过程与实际案例
查看>>