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

JDK6: scanner.findInLine() does not work with embedded flag expression "(?s)"

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P3 P3
    • None
    • 6
    • core-libs
    • None
    • x86
    • windows_xp

      The result of following is different in JDK1.5 and JDK6.

        Scanner scanner = new Scanner("\n");
        String result = scanner.findInLine("(?s).*");
        System.out.print(result);

      It seems that JDK6 does not work with embedded flag expression "(?s)".
      I'm trying on Windows XP.

        JDK1.5 (1.5.0_10-b03)
      result : \n
        JDK6 (j1.6.0-b105, 1.6.0_01-ea-b02)
      result: null

      The following example using Pettern and "(?s)" returns the
      expected result on both JDK1.5 and JDK6, so it seems that
      the behavior of Scanner class is changing.

        Pattern pattern = Pattern.compile("(?s).*");
        Matcher matcher = pattern.matcher("\n");
        System.out.println(matcher.matches());

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: