English 中文(简体)
我为什么在 Java看到非法越狱的性质? [复制]
原标题:Why am I getting illegal escape characters with regexp in Java? [duplicate]
  • 时间:2010-04-01 16:16:11
  •  标签:
  • java
  • regex

I m working on a simply password strength checker and i can not success applying regular expressions. In different resources different kinds of regular expressions are defined. i also find javascript regular expressions but had some problems to adapt.

首先,这些是经常表达,即需要JAVA:

  • at least one lower case letter
  • at least one upper case letter at least
  • one number at least three numbers at
  • least one special character at least
  • two special characters both letters
  • and numbers both upper and lower case
  • letters, numbers, and special characters

我的目标不是定期的表达专家,而只是想利用需要的部分。 如果你把上文讨论的内容引向上调java,将不胜感激。

第二,在上 其中一些问题被提及,但一刀切,难以适用。

这里不收下案卷(我的通行证:A5677a)

if (passwd.matches("(?=.*[a-z])")) // [verified] at least one lower case letter {Score = Score+5;}

这里还有一滴错误:非法越狱的性质。

如果(绕过......)(?=*d)) /[核实]至少一个编号

最后,这些表述在不同的方案拟订或文字语言中是否不同?

最佳回答
问题回答

我认为,在这种情况下使用一种定期表达方式会非常低效率。 定期表达不是为了跟踪你有多少x、ys和z(X、y和z是以上所列任何标准)——这意味着你需要采用多种定期表述(如你以你为例所做的那样),每一次都可以按部就班。

为什么不只写一个处理功能,在你的密码中审查每个特性? 您可以通过单一通行证进行整个检查。

部分例子:

public boolean isStrong(String toCheck) {
    boolean hasLower = false;
    boolean hasUpper = true;

    for (int i = 0; i < toCheck.length(); i++) {
      char next = toCheck.charAt(i);
      if (Character.isLower(next)) {
        hasLower = true;
      } else if (Character.isUpper(next)) {
        hasUpper = true;
      }
    }

    return hasLower && hasUpper;
}

<>strong>Edit:我刚刚注意到,你正在计算一个记分数,而不是核对弱小诉强;这可以很容易地加以调整。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...