我的Android进阶之旅------>解决错误: java.util.regex.PatternSyntaxException: Incorrect Unicode property
1、错误描述
今天使用正则表达式验证密码的时候,报了错误
java.util.regex.PatternSyntaxException: Incorrect Unicode property near index 32:
错误具体输出日志如下:
04-28 12:49:46.254 2224-2224/com.xtc.watch E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.xtc.watch, PID: 2224
java.util.regex.PatternSyntaxException: Incorrect Unicode property near index 32:
^(?![0-9]+$)(?![a-zA-Z]+$)(?!\pP+$)(\S){6,16}$
^
at java.util.regex.Pattern.compileImpl(Native Method)
at java.util.regex.Pattern.compile(Pattern.java:411)
at java.util.regex.Pattern.<init>(Pattern.java:394)
at java.util.regex.Pattern.matches(Pattern.java:424)
at java.lang.String.matches(String.java:1334)
该正则表达式的代码如下所示:
String regex = "^(?![0-9]+$)(?![a-zA-Z]+$)(?!\\pP+$)(\\S){6,16}$";
2、解决方法
通过百度,查到一篇文章解决了该bug。该文章链接地址是:
http://stackoverflow.com/questions/22665156/incorrect-unicode-property-near-index
尝试把 \pP改成\p{P}
即将上面报错的错误正则表达式
String regex = "^(?![0-9]+$)(?![a-zA-Z]+$)(?!\\pP+$)(\\S){6,16}$";
变成正确的正则表达式
String regex = "^(?![0-9]+$)(?![a-zA-Z]+$)(?!\\p{P}+$)(\\S){6,16}$";
这样就解决了该bug。
作者:欧阳鹏 欢迎转载,与人分享是进步的源泉!
转载请保留原文地址:http://blog.csdn.net/ouyang_peng
我的Android进阶之旅------>解决错误: java.util.regex.PatternSyntaxException: Incorrect Unicode property的更多相关文章
- 我的Android进阶之旅------>解决错误:You need to use a Theme.AppCompat theme (or descendant) with this activity.
#1.错误描述 今天,想实现Activity不显示标题栏的效果,在项目的AndroidManifest.xml文件,对相应的Activity添加属性 android:theme="@andr ...
- java.util.regex.PatternSyntaxException: Unclosed character class near index解决办法
使用str.split("[")时,出现java.util.regex.PatternSyntaxException: Unclosed character class near ...
- Exception in thread "main" java.util.regex.PatternSyntaxException: Unclosed character class near index 0 解决方法: 要对切割字符进行转义\\
使用str.split("[",15)时,出现Exception in thread "main" java.util.regex.PatternSyntaxE ...
- 我的Android进阶之旅------>解决Jackson等第三方转换Json的开发包在开启混淆后转换的实体类数据都是null的bug
1.错误描述 今天测试人员提了一个bug,说使用我们的app出现了闪退的bug,后来通过debug断点调试,发现我们的app转换服务器发送过来的json数据后,都是为null.而之前已经提测快一个月的 ...
- 我的Android进阶之旅------>解决DownloadManager报错java.lang.SecurityException: Invalid value for visibility: 2
1.问题描述 今天使用Android系统的DownloadManager进行下载操作时,爆了如下所示的错误: java.lang.RuntimeException: Unable to start s ...
- 我的Android进阶之旅------>解决Jackson、Gson解析Json数据时,Json数据中的Key为Java关键字时解析为null的问题
1.问题描述 首先,需要解析的Json数据类似于下面的格式,但是包含了Java关键字abstract: { ret: 0, msg: "normal return.", news: ...
- 我的Android进阶之旅------>解决AES加密报错:java.security.InvalidKeyException: Unsupported key size: 18 bytes
1.错误描述 今天使用AES进行加密时候,报错如下所示: 04-21 11:08:18.087 27501-27501/com.xtc.watch E/AESUtil.decryptAES:55: j ...
- 我的Android进阶之旅------>解决如下错误failed to copy 'Settings2.apk' to '/system/app//Settings2.apk': Read-only
push apk的时候报错 ouyangpeng@oyp-ubuntu:~/apk升级$ adb push Settings2.apk /system/app/ failed to copy 'Set ...
- 我的Android进阶之旅------>解决Error: specified for property 'mergedManifest' does not exist.
错误描述 刚运行从Github上面下载而来的代码时,爆了如下所示的bug,错误描述如下所示: Error:A problem was found with the configuration of t ...
随机推荐
- CCNA2.0笔记_TCP/IP概述
主机到主机层(传输层) TCP与UDP UDP的特点 运行于 OSI 模型和 TCP/IP 模型的传输层 为应用程序提供网络层接入而无需为可靠性机制付出多余开销 属无连接协议 提供有限的错误检查 提供 ...
- [转]c++ virtual public的含义和作用
我在写基于MICO的CORBA程序的时候遇到的,上网查了一下 转自:http://bbs.seu.edu.cn/pc/pccon.php?id=872&nid=16822 Question:父 ...
- linux学习笔记16--命令find
find是linux系统中用的比较多的一个命令,而且功能强大,特别是对各种查找方式的不确定位置的文件的查找. Linux下find命令在目录结构中搜索文件,并执行指定的操作.Linux下find命令提 ...
- spring-jmx.xml
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...
- deep learning+ Depth Estimation
Depth estimation/stereo matching/optical flow @CVPR 2017 Unsupervised Learning of Depth and Ego-Moti ...
- Html就是超文本标记语言的简写,是最基础的网页语言
Html就是超文本标记语言的简写,是最基础的网页语言. Html是通过标签来定义的语言,代码都是由标签所组成. Html代码不用区分大小写. Html代码由<html>开始</htm ...
- boost数据结构variant
variant和any有些类似,是一种可变类型,是对C/C++中union概念的增强和扩展: 普通的union只能持有普通数据类型,而不能持有string.vector等复杂类型,而varian ...
- apache 一个站点配置多个域名
<VirtualHost *:80> ServerAdmin i@kuigg.com DocumentRoot /www/kuigg.com ServerName kuigg.com ...
- iOS-UIScrollView拉伸效果
解决办法: 比如登录界面是可以上下拉伸的(微信),在ScrollView里调用一下这个方法即可. scrollView.alwaysBounceVertical = YES;
- hiho一下第109周《Tower Defense Game》
题目链接:传送门 题目大意:给你一棵树,根节点为1,树上每一个节点都有一个花费值和收入值(花费值>=收入值),要访问一个节点需先支付花费值,访问该节点结束后得到收入值 同时访问树时要求是有序的, ...