[英]regular-expression in java
I am using this regular expression in a java file to validate the password. 我在Java文件中使用此正则表达式来验证密码。
"^\w*(?=\w*\d)(?=\w*[a-z])(?=\w*[A-Z])\w*$"
It's showing the error : 显示错误:
Invalid escape sequence (valid ones are \b \t \n \f \r \" \' \\ )
Can anybody tell me what mistake I am doing in this?(I don't know anything about regular expressions. I copied it from google.) 有人可以告诉我我在这方面犯了什么错误吗?(我对正则表达式一无所知。我从Google复制了它。)
In Java string literals you need to escape the backslashes. 在Java字符串文字中,您需要转义反斜杠。
"^\\w*(?=\\w*\\d)(?=\\w*[a-z])(?=\\w*[A-Z])\\w*$"
You can also simplify your regular expression by removing the first \\\\w*
as it is not needed. 您也可以通过删除不需要的第一个\\\\w*
来简化正则表达式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.