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. numpy.ravel()/numpy.flatten()/numpy.squeeze()

    numpy.ravel(a, order='C') Return a flattened array numpy.chararray.flatten(order='C') Return a copy ...

  2. InnoDB:表

    数据在表中是如何进行组织存放的?下面我们就来看看: InnoDB引擎表的类型 InnoDB表都会有一个主键. 如果没有显示的指定主键,首先会去查找,看是否有非空的唯一索引, 如果有,则该列为主键:如果 ...

  3. iOS 小数点精度问题处理

    实际开发中有时候经常会需要去处理小数点精度问题,如果是整数保留整数,如果有小数则保留不为0的的小数,最大2位小数 eg: 2.013 ---> 2.01 2.0 ---> 2 2.10 - ...

  4. Caffe在以下环境安装:Win10+CUDA8.0+Cudnn5.0+VS2013+Matlab2016a(转载)

    Caffe在以下环境安装:Win10+CUDA8.0+Cudnn5.0+VS2013+Matlab2016a 最近于导师要求下,从头学习Caffe.之前接触了CNN进行了图片分类,后导师提起过Caff ...

  5. 每隔10秒自动更新svn 定时更新svn 脚本

    任务: */1 * * * * /opt/adobe/fms/webroot/api/svn.sh 这个命令的问题:只更新了版本号,没有更新实际内容,但是直接运行上面shell脚本能更新. 解决:需要 ...

  6. Django - 安装filebrowser发生Error finding Upload-Folder错误

    Error finding Upload-Folder (site.storage.location + site.directory). Maybe it does not exist? 解决: F ...

  7. windows连接远程打印机

    windows连接hp的远程打印机时,自动装不了驱动.. 需打开驱动程序(驱动程序安装需接设备),然后windows就过下载驱动这步了..

  8. 第7步:安装Grid

    7.1解压文件 注意,安装Grid时需要以grid用户身份执行,在那之前需要以root身份执行xhost+,即命令: 代码1 [root@sgdb1~]# xhost+ [root@sgdb1~]# ...

  9. SmartStoreNet解图

    概述: Ioc: Autofac 1. 通过继承, 对MVC的Controller的加强.

  10. IO文件读写

    *b表示二进制模式访问,但是对于Linux或者Unix系统来说这个模式没有任何意义,因为他们把所有文件都看做二进制文件,包括文本文件 一.三种方法读取文件  方法1:open f=open(" ...