Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6451717

Regex: Nodes (Not)?Single[A|U] report wrong hitEnd status when failed to match/find (5.0)

XMLWordPrintable

    • b01
    • generic
    • generic

      Regex nodes SingleA, NotSingleA, SingleU and NotSingleU always report the
      hitEnd() to be true when match/find failed, even the "end" has not been reached.

      The cases below show the problem.

              // SingleA
      p = Pattern.compile("^a", Pattern.CASE_INSENSITIVE);
      m = p.matcher("bcd");
      if (m.find() || m.hitEnd()) {
      failCount++;
      }

              // NotSingleA
      p = Pattern.compile("^[^\u4e00]", Pattern.CASE_INSENSITIVE);
      m = p.matcher("\u4e00cd");
      if (m.find() || m.hitEnd()) {
      failCount++;
      }

              // SingleU
      p = Pattern.compile("^\u4e00", Pattern.CASE_INSENSITIVE |Pattern.UNICODE_CASE);
      m = p.matcher("abc");
      if (m.find() || m.hitEnd()) {
      failCount++;
      }

              // NotSingleU
      p = Pattern.compile("^[^\u03b2]", Pattern.CASE_INSENSITIVE |Pattern.UNICODE_CASE);
      m = p.matcher("\u0392bc");
      if (m.find() || m.hitEnd()) {
      failCount++;
      }

            sherman Xueming Shen
            sherman Xueming Shen
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: