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. makefile之命令包&多行变量

    define&endef 1. 命令包(canned recipes)&多行变量(muti-line variables) The define directive is follow ...

  2. CSU 1329: 一行盒子

    1329: 一行盒子 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 740  Solved: 145[Submit][Status][Web Board ...

  3. Oracle之比较NVARCHAR2字符串

    一.引言 昨天遇到一个问题,一直想不通是为什么,我在pl/sql里面执行sql语句,选出字段值等于某个值的的行: '; 用select * from test;是可以查到该值的,但是用这条语句却没有结 ...

  4. JavaScript 数组-Array的方法总结

    JavaScript中的Array类型是经常用到的,Array类型也提供了很多方法能实现我们需求,下面我们来总结一下 一.创建Array的方法 1.使用Array构造函数 var colors=new ...

  5. ExtPager ,分页

    package cn.edu.hbcf.common.vo; public class ExtPager { private Integer start; private Integer limit; ...

  6. IPC之共享内存

    man 7 shm_overview shm_overview - Overview of POSIX shared memory. 同样,SystemV实现的共享内存是旧的机制,但应用广泛:Posi ...

  7. 【Mac + Appium + Python3.6学习(六)】之安装Android模拟器(Genymotion)并运行模拟器进行自动化

    环境: MacOS:10.13.6 Virtualbox:5.2.22 Genymotion:genymotion-2.12.2 本文Virtualbox.Genymotion下载地址: 链接:htt ...

  8. CentOS7.1 安装Liberty之环境准备(1)

    一.基础平台 1.一台装有VMware的windows系统(可联网) 2.CentOS 7.1 64bit镜像 二.最小化安装两台CentOS 7.1 的虚拟机controller.compute1, ...

  9. TortoiseGit上传项目代码到github方法(超简单)

    Github是咱广大开发者用的非常多的项目代码版本管理网站,项目托管可以是私人的(private)或者公开的(public),私人的收费,一个月7美金.咱这里就只说我们个人使用的,一般都是代码对外开放 ...

  10. webservice linux 杀进程

    一 .  linux 下首先查看进程 ./stopServcer.sh server1如果停不掉websphere服务.则强制杀掉其进程! 1.查看websphere进程号bejqylc06:~ #  ...