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的更多相关文章

  1. 我的Android进阶之旅------>解决错误:You need to use a Theme.AppCompat theme (or descendant) with this activity.

    #1.错误描述 今天,想实现Activity不显示标题栏的效果,在项目的AndroidManifest.xml文件,对相应的Activity添加属性 android:theme="@andr ...

  2. java.util.regex.PatternSyntaxException: Unclosed character class near index解决办法

    使用str.split("[")时,出现java.util.regex.PatternSyntaxException: Unclosed character class near  ...

  3. 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 ...

  4. 我的Android进阶之旅------>解决Jackson等第三方转换Json的开发包在开启混淆后转换的实体类数据都是null的bug

    1.错误描述 今天测试人员提了一个bug,说使用我们的app出现了闪退的bug,后来通过debug断点调试,发现我们的app转换服务器发送过来的json数据后,都是为null.而之前已经提测快一个月的 ...

  5. 我的Android进阶之旅------>解决DownloadManager报错java.lang.SecurityException: Invalid value for visibility: 2

    1.问题描述 今天使用Android系统的DownloadManager进行下载操作时,爆了如下所示的错误: java.lang.RuntimeException: Unable to start s ...

  6. 我的Android进阶之旅------>解决Jackson、Gson解析Json数据时,Json数据中的Key为Java关键字时解析为null的问题

    1.问题描述 首先,需要解析的Json数据类似于下面的格式,但是包含了Java关键字abstract: { ret: 0, msg: "normal return.", news: ...

  7. 我的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 ...

  8. 我的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 ...

  9. 我的Android进阶之旅------>解决Error: specified for property 'mergedManifest' does not exist.

    错误描述 刚运行从Github上面下载而来的代码时,爆了如下所示的bug,错误描述如下所示: Error:A problem was found with the configuration of t ...

随机推荐

  1. 查看linux内核和版本信息

    一.查看Linux内核版本命令(2种方法): 1.cat /proc/version Linux version 3.10.0_1-0-0-8 (root@xxx) (gcc version 4.8. ...

  2. poj Ping pong LA 4329 (树状数组统计数目)

    Ping pong Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2302   Accepted: 879 Descript ...

  3. SOCK_RAW编程

    TCP(SOCK_STREAM)和UDP套接口(SOCK_DGRAM)可以满足大部分需求,但要获取底层协议内容就需要原始套接字.相比前两者,SOCK_RAW具有如下优点: 1)使用原始套接字可以读写I ...

  4. windows下搭建ffmpeg+nginx+rtmp-module搭建实时视频环境

    下载ffmpeg的Windows静态版: https://ffmpeg.zeranoe.com/builds/win64/static/下载nginx-rtmp-windows版:https://gi ...

  5. Centos7安装Apache Http服务器无法访问如何解决

    1. 安装Apache组件 [root@mycentos shell]# yum install httpd 2. 安装成功后,检测有无httpd进程 [root@mycentos shell]# p ...

  6. 初识NuGet及快速安装使用

    为什么要使用NuGet 简单的说NuGet可以是我们的工作更方便,当我们的项目里要引用到的一些库时候,比如JQuery.Newtonsoft.Json. log4net等,我们需要从网上下载这些库,然 ...

  7. ARGOX 力象 OS-214Plus 条码打印机 B/S 打印

    官网demo下载地址: http://www.argox.com.cn/servicedev/5/c 页面中嵌入activeX控件: <object id="ArgoxPrinter& ...

  8. iOS开发-你真的会用SDWebImage?

    SDWebImage作为眼下最受欢迎的图片下载第三方框架,使用率非常高.可是你真的会用吗?本文接下来将通过例子分析怎样合理使用SDWebImage. 使用场景:自己定义的UITableViewCell ...

  9. requirejs学习(一)

    requirejs学习(一) 随着网站功能逐渐丰富,网页中的js也变得越来越复杂和臃肿,各种依赖(插件等)也逐渐增多,原有通过script标签来导入一个个的js文件这种方式已经不能满足现在的需求,我们 ...

  10. FireBug与FirePHP

    a.FireBug,平时用的比较多.就是在客户端调试代码.如:hTML ,CSS,JS等 b.FireBug安装较容易. b-1,打开火狐浏览器 b-2,打开“附加组件” b-3.搜索“firebug ...