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

Add doc describing how (?x) ignores spaces in character classes

XMLWordPrintable

      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)

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

              Created:
              Updated:
              Resolved: