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

String.replaceAll regular expression behaves differently in Java 11 and Java 8

    XMLWordPrintable

Details

    • generic
    • generic
    • Not verified

    Description

      ADDITIONAL SYSTEM INFORMATION :
      Tested on Unix, but shouldn't matter.

      A DESCRIPTION OF THE PROBLEM :
      Not sure if it's a bug or Java 11 enhancement but repressions in following format give different results in Java 11 and Java 8: "[^x-y&&[^w]]"

      For example, following code will generate different results in Java11 and Java 8:
      String test1="AcB";
      String test2=test1.replaceAll("^A-Z&&[^c]", "x");
      //in Java 8, test2="AcB", Java 11, test2="AxB"


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Not sure if it's a bug or Java 11 enhancement but repressions in following format give different results in Java 11 and Java 8: "[^x-y&&[^w]]"


      String test1="AcB";
      String test2=test1.replaceAll("^A-Z&&[^c]", "x");
      //in Java 8, test2="AcB", Java 11, test2="AxB"



      FREQUENCY : always


      Attachments

        Activity

          People

            tongwan Andrew Wang
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: