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

regex ranges cannot include escaped characters

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.4.0
    • 1.4.0
    • core-libs
    • None
    • beta
    • x86
    • windows_nt
    • Verified


      I was trying to create a range that was all characters except a specific
      character that I described by an octal escape sequence. However the
      escape sequence was rejected with the error below.

      Exception in thread "main" java.util.regex.PatternSyntaxException: unexpected
      error in character range around index 30
              \smethod=POST\s+action=([^\076]*)
                                           ^

      This appears to be one symptom of a more general bug that escape characters
      aren't accepted within ranges. See the simple test case below.

      Given that many interesting characters may need to be escaped to be used in
      regular expressions, this looks like it could be a limitation.


      public class Test {

          public static void main(String argv[]) throws Exception {

              java.util.regex.Pattern.compile("[\\t]");
          }
      }


      graham.hamilton@Eng 2001-02-22

            mmcclosksunw Michael Mccloskey (Inactive)
            ghamiltosunw Graham Hamilton (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: