我的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 ...
随机推荐
- mysql 两列互转
1.mysql 一张表两列互转 UPDATE tm_position as a,tm_position as b SET a.gps_longitude = b.gps_latitude,a.gps_ ...
- html 基本标签 ---字体
<b> </b>加粗 <i> </i> 斜体 <del> </del> 删除 <ins> </ins> ...
- 完整的jdbc查询结果集编码
public static ArrayList<HashMap<String,Object>> query(Connection conn,String sql, Object ...
- [转]Spark能否取代Hadoop?
大数据的浪潮风靡全球的时候,Spark火了.在国外 Yahoo!.Twitter.Intel.Amazon.Cloudera 等公司率先应用并推广 Spark 技术,在国内阿里巴巴.百度.淘宝.腾讯. ...
- 【Python】分享使用的插件文件链接(实时更新)
链接:https://pan.baidu.com/s/1o7AgHtw Python工具实时更新.
- Splash 笔记
javascript rendering service a lightweight web browser can execute custom JavaScript in page context ...
- EasyUI DataGrid可编辑单元格
效果如图: 首先在需要可编辑的列上添加一个editor属性,列定义为numberbox编辑类型 <th field="SCORES" editor="{type:' ...
- 关于JSON日期格式显示及My97日期控件
1.My97日期控件.显示不同的日期格式,可以调整"dateFmt“的参数来配置: 详细DEMO:http://www.my97.net/demo/index.htm <p>日期 ...
- Java将视频转为缩略图--ffmpeg
Java生成视频缩略图 对于上传视频生成缩略图使用的是ffmpeg进行生成的. 自己在网上找了如何进行编译ffmpeg的方法 但是感觉太复杂了 就到csdn上找到了编译好的ffmpeg文件 体会到ff ...
- Hadoop2的FN安装(federated namespace)
尝试了简单的安装hadoop2后,我们再来尝试一下hdfs的一项新功能:FN.这项技术可以解决namenode容量不足的问题.它采用多个namenode来共享datanode的方式,每个namenod ...