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

Matcher.group() can return null after usePattern

XMLWordPrintable

    • b13
    • generic
    • generic
    • Verified

      A DESCRIPTION OF THE PROBLEM :
      The documentation for Matcher.group() does not mention that it can return null, however when using Matcher#usePattern after a successful match, the method will return null.


      ---------- BEGIN SOURCE ----------
      Matcher matcher = Pattern.compile("a").matcher("a");
      matcher.find();
      matcher.usePattern(Pattern.compile("pattern"));
      System.out.println(matcher.group()); // returns null
      ---------- END SOURCE ----------

            igraves Ian Graves
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: