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

output is different for \p{Lower} w.r.t [a-z] in case of case-insensitive

    Details

      Description

      A DESCRIPTION OF THE PROBLEM :
      https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html
      \p{Lower} A lower-case alphabetic character: [a-z]

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      public class HelloWorld{
           public static void main(String []args){
              Pattern p=Pattern.compile("[\\p{Lower}]",Pattern.CASE_INSENSITIVE);
               
              Matcher m=p.matcher("CF@ampim");
              if(m.find())
                      System.out.println(" Result : "+m);
           }
      }

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Result : java.util.regex.Matcher[pattern=[a-z] region=0,8 lastmatch=C]
      ACTUAL -
       Result : java.util.regex.Matcher[pattern=[\p{Lower}] region=0,8 lastmatch=a]

      ---------- BEGIN SOURCE ----------
      public class HelloWorld{
           public static void main(String []args){
              Pattern p=Pattern.compile("[\\p{Lower}]",Pattern.CASE_INSENSITIVE);
               
              Matcher m=p.matcher("CF@ampim");
              if(m.find())
                      System.out.println(" Result : "+m);
           }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      incase of case-insensitive, use this java regex "[a-z]"

      public class HelloWorld{
           public static void main(String []args){
              Pattern p=Pattern.compile("[a-z]",Pattern.CASE_INSENSITIVE);
               
              Matcher m=p.matcher("CF@ampim");
              if(m.find())
                      System.out.println(" Result : "+m);
           }
      }

      FREQUENCY : always


        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: