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

Regex Pattern class improperly ignores spaces in character classes

    Details

      Description

      FULL PRODUCT VERSION :

      A DESCRIPTION OF THE PROBLEM :

      Using the regex "[ ]" works, but using "(?x)[ ]" does not. The whitespace is ignored and the result is an error. There's a stackoverflow post about it here: https://stackoverflow.com/questions/49264034/

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Whitespace should be ignored when using the x flag (COMMENTS) but not when it's in a character class

      REPRODUCIBILITY :
      This bug can be reproduced always.

      CUSTOMER SUBMITTED WORKAROUND :
      Escaping the space or moving the inline modifier to after the character class works:

      x flag with "\\ " or "[\\ ]"
      Other option "[ ](?x)

        Attachments

          Activity

            People

            • Assignee:
              dkejriwal Deepak Kejriwal (Inactive)
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated: