java.lang.IllegalArgumentException: character to be escaped is missing

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • FULL PRODUCT VERSION : java version "1.8.0_92" Java(TM) SE Runtime Environment (build 1.8.0_92-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode) ADDITIONAL OS VERSION INFORMATION : Microsoft Windows [Version 6.1.7601] A DESCRIPTION OF THE PROBLEM : StringObject.replaceAll(the_regex_here, "\\"); throwing exception and instead of replacing the thing. NOTE: it's only happening when there's only single \ characters in the replaceWith field. STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : // THE LAST TWO STATEMENTS PRODUCES THE EXCEPTION public class RegexCheck { public static void main(String[] args) { System.out.println("abc\\\\def".replaceAll("\\\\", ".")); System.out.println("abc..def".replaceAll("\\.\\.", ".")); System.out.println("abc..def".replaceAll("\\.\\.", "\\*")); System.out.println("abc..def".replaceAll("\\.\\.", "\\\\")); System.out.println("abc..def".replaceAll("\\.\\.", "\\")); System.out.println("abc\\\\def".replaceAll("\\\\", "\\")); } } EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - abc..def abc.def abc*def abc\def abc\def ACTUAL - abc..def abc.def abc*def abc\def Exception in thread "main" java.lang.IllegalArgumentException: character to be escaped is missing at java.util.regex.Matcher.appendReplacement(Unknown Source) at java.util.regex.Matcher.replaceAll(Unknown Source) at java.lang.String.replaceAll(Unknown Source) at RegexCheck.main(RegexCheck.java:7) ERROR MESSAGES/STACK TRACES THAT OCCUR : Exception in thread "main" java.lang.IllegalArgumentException: character to be escaped is missing at java.util.regex.Matcher.appendReplacement(Unknown Source) at java.util.regex.Matcher.replaceAll(Unknown Source) at java.lang.String.replaceAll(Unknown Source) at RegexCheck.main(RegexCheck.java:7) REPRODUCIBILITY : This bug can be reproduced always. SUPPORT : YES
    via by Webbug Group,
  • GitHub comment 1391#148500141
    via GitHub by rbhunt
    ,
  • GitHub comment 1623#160474851
    via GitHub by Stormyy
    ,
  • Codegenerator fails on Windows
    via GitHub by Stormyy
    ,
  • GitHub comment 4#157308957
    via GitHub by WangWeiHuawwh
    ,
    • java.lang.IllegalArgumentException: character to be escaped is missing at java.util.regex.Matcher.appendReplacement(Unknown Source) at java.util.regex.Matcher.replaceAll(Unknown Source) at java.lang.String.replaceAll(Unknown Source) at RegexCheck.main(RegexCheck.java:7)

    Users with the same issue

    Unknown visitor1 times, last one,
    Unknown visitor1 times, last one,
    Axelo
    Axelo5 times, last one,
    treanz
    treanz1 times, last one,
    Unknown visitor1 times, last one,
    15 more bugmates