java正则总是:java.lang.IllegalStateException: No match found 的分析解决
来源:互联网 发布:大麦户2016源码 编辑:程序博客网 时间:2024/09/21 09:03
package com.quanran;import java.util.regex.Matcher;import java.util.regex.Pattern;public class RegexTest {/** * <p>Discription:[根据传入的regex正则表达式,找到source中的匹配部分]</p> * Created on 2017年12月22日 下午2:12:12 * @param regex 正则表达式 * @param source 源文件 * @return String 返回匹配到的字符串 * @author:[全冉] */private static String getMatcher(String regex, String source) { String result = ""; Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(source); while (matcher.find()) { result = matcher.group();} return result; } public static void main(String[] args) {String str = getMatcher("\\d{11}$", "全冉15175223269");System.out.println(str);}}备注:想要matcher.group()方法,必须先matcher.find()方法,切忌!要不然总是报:
java.lang.IllegalStateException: No match found
阅读全文
0 0
- java正则总是:java.lang.IllegalStateException: No match found 的分析解决
- java.lang.IllegalStateException: No match found 的分析解决
- java.lang.IllegalStateException: No match found错误
- java正则java.lang.IllegalStateException: No match found关于find和group方法使用问题
- 正则表达式出现的一个错误java.lang.IllegalStateException: No successful match so far
- java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?
- java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered
- javax.servlet.ServletException: java.lang.IllegalStateException: No WebApplicationContext found: no
- java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered
- 已解决java.lang.IllegalStateException: No MethodInvocation found: Check that an AOP invocation
- java.lang.IllegalStateException解决
- java.lang.IllegalStateException: No activity
- java.lang.IllegalStateException: No activity
- java.lang.IllegalStateException: No activity
- java.lang.IllegalStateException: No activity
- java.lang.IllegalStateException: No activity
- java.lang.IllegalStateException: No activity
- java.lang.IllegalStateException: No host
- Dubbo远程方法注册
- PyCharm默认快捷键映射中文版
- Oracle与MySql 分别查看字段名称 类型 长度 注释
- gcc,g++编译链接有关的路径
- 微信小程序----引入外部字体库iconfont的图标
- java正则总是:java.lang.IllegalStateException: No match found 的分析解决
- Oracle 11g RAC关机 开机操作步骤
- 44. Building Your Own Application
- Java语言编码规范(参考)
- ZXing笔记(2)—portrait ZXing,竖直扫码
- linux 内核驱动加载
- 深度学习——感知器
- 第一人称视角获得运动方向和视角的夹角
- 【C++温故】(3)类的拷贝构造函数 & =重载函数