java.lang.IllegalArgumentException: Illegal group reference

JDK Bug System | Webbug Group | 4 months ago
  1. 0

    FULL PRODUCT VERSION : java version "1.8.0_73" Java(TM) SE Runtime Environment (build 1.8.0_73-b02) Java HotSpot(TM) Client VM (build 25.73-b02, mixed mode, sharing) ADDITIONAL OS VERSION INFORMATION : Windows 10 EXTRA RELEVANT SYSTEM CONFIGURATION : In Matcher.java line 854 is written: // The first number is always a group refNum = (int)nextChar - '0'; if ((refNum < 0)||(refNum > 9)) throw new IllegalArgumentException( "Illegal group reference"); That the first character after $ is always a number is not correct. A DESCRIPTION OF THE PROBLEM : That the first character after $ is always a number is not correct. STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : public static void main(String[] args) { final String k = "1234"; System.out.println(k.replaceAll("23", "$&")); } ACTUAL - Exception in thread "main" java.lang.IllegalArgumentException: Illegal group reference at java.util.regex.Matcher.appendReplacement(Matcher.java:857) at java.util.regex.Matcher.replaceAll(Matcher.java:955) at java.lang.String.replaceAll(String.java:2210) at overlay.StartupTest.main(StartupTest.java:52) ERROR MESSAGES/STACK TRACES THAT OCCUR : Exception in thread "main" java.lang.IllegalArgumentException: Illegal group reference at java.util.regex.Matcher.appendReplacement(Matcher.java:857) at java.util.regex.Matcher.replaceAll(Matcher.java:955) at java.lang.String.replaceAll(String.java:2210) at overlay.StartupTest.main(StartupTest.java:52) REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- public static void main(String[] args) { final String k = "1234"; System.out.println(k.replaceAll("23", "$&")); } ---------- END SOURCE ----------

    JDK Bug System | 4 months ago | Webbug Group
    java.lang.IllegalArgumentException: Illegal group reference
  2. 0

    Replace all ocurrences by string with special characters in java

    Stack Overflow | 2 years ago | victorpacheco3107
    java.lang.IllegalArgumentException: Illegal group reference
  3. 0

    IllegalArgumentException into Mapper Generator

    GitHub | 3 years ago | Tolsi
    java.lang.IllegalArgumentException: Illegal group reference
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    "IllegalArgumentException: Illegal group reference" in doUses when package name contains $

    GitHub | 5 years ago | pmoriarty
    java.lang.IllegalArgumentException: Illegal group reference
  6. 0

    how do i replace any string with a "$ " in java?

    Stack Overflow | 6 years ago | tasa
    java.lang.IllegalArgumentException: Illegal group reference

  1. treanz 1 times, last 5 months ago
  2. Larten 2 times, last 9 months ago
8 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.lang.IllegalArgumentException

    Illegal group reference

    at java.util.regex.Matcher.appendReplacement()
  2. Java RT
    String.replaceAll
    1. java.util.regex.Matcher.appendReplacement(Matcher.java:857)
    2. java.util.regex.Matcher.replaceAll(Matcher.java:955)
    3. java.lang.String.replaceAll(String.java:2210)
    3 frames
  3. overlay
    StartupTest.main
    1. overlay.StartupTest.main(StartupTest.java:52)
    1 frame