小编log*_*sex的帖子

在Java中使用Matcher时出现无限循环

我正在学习正则表达式,我有这段代码:

private static final String FILE_BEGINNING_PATTERN = "^(,Share %)";

public static void main(String[] args) {
    String str = ",Share %,\"Date Purchased\",Display Name,Address,Phone,Fax,Mobile,Email,";

    Matcher beginningFileMatcher = Pattern.compile(FILE_BEGINNING_PATTERN).matcher(str);
    if (beginningFileMatcher.find()) {
        System.out.println("Regex match!");
    }

    // find() method starts at the beginning of this matcher's region, or, if
    // a previous invocation of the method was successful and the matcher has
    // not since been reset, at the first character not matched by the previous
    // match.
    //

    int count = 0;
    while …
Run Code Online (Sandbox Code Playgroud)

java regex

1
推荐指数
1
解决办法
898
查看次数

== 运算符比 equals() 更快吗?

我正在学习 String intern() 方法并且知道 intern() 帮助我可以使用“==”运算符来比较 String 对象而不是 equals() 方法,并且一些文档更快地引用了它。不是吗?

https://dzone.com/articles/string-interning-what-why-and

java string

-2
推荐指数
1
解决办法
77
查看次数

标签 统计

java ×2

regex ×1

string ×1