7 Replies Latest reply: Mar 6, 2008 9:56 PM by 807601 RSS

    replaceAll, regex Pattern exception

    807601
      this line of code...
      string = string.replaceAll("\\", "");
      gives me this error...
      Exception in thread "main" java.util.regex.PatternSyntaxException: Unexpected internal error near index 1
      \
      ^
           at java.util.regex.Pattern.error(Unknown Source)
           at java.util.regex.Pattern.compile(Unknown Source)
           at java.util.regex.Pattern.<init>(Unknown Source)
           at java.util.regex.Pattern.compile(Unknown Source)
           at java.lang.String.replaceAll(Unknown Source)

      any idea why? When I comment this line out it works it works fine no errors and it does what I want! But I thought double slash was an escape character, do I have to do this differently? Thanks!

      Edited by: didittoday on Mar 6, 2008 5:22 PM

      Edited by: didittoday on Mar 6, 2008 5:22 PM