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

Matcher matches a surrogate pair that crosses border of the region

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 14
    • None
    • core-libs
    • None

      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());
          }
      }

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

              Created:
              Updated:
              Resolved: