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

Matcher matches a surrogate pair that crosses border of the region

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 14
    • Component/s: core-libs
    • Labels:
      None

      Description

      java.util.regex.Matcher does not respect the boundary specified by the method region(int, int) when matching against a supplementary character.

      The following code is expected to print "false", but prints "true":
      import java.util.regex.*;

      public class T {
          public static void main(String[] args) throws Throwable {
              Pattern p = Pattern.compile("\\ud800\\udc61");
              Matcher m = p.matcher("\ud800\udc61");
              m.region(0, 1);
              System.out.println(m.find());
          }
      }

        Attachments

          Activity

            People

            Assignee:
            igerasim Ivan Gerasimov
            Reporter:
            igerasim Ivan Gerasimov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: