title: IntelliJ says "\\" (match on single backslash) is an illegal / unsupported escape sequence for Pattern.compile
body: <p>The following pattern compile expression gives error in IntelliJ, even though the expression compiles and works well in Java (1.8):</p>
  
  <pre><code>Pattern.compile("\\", Pattern.LITERAL);
  </code></pre>
  
  <p>I´m using the following code to escape all occurences of <code>\</code> in a String with a double <code>\\</code>, like this:</p>
  
  <pre><code>private final static Pattern BACKSLASH_PATTERN = Pattern.compile("\\", Pattern.LITERAL);
  private final static String BACKSLASH_REPLACE = Matcher.quoteReplacement("\\\\");
  
  private String escapeBackslashes(final String s) { 
      return BACKSLASH_PATTERN.matcher(s).replaceAll(BACKSLASH_REPLACE);
  }
  </code></pre>
  
  <p>When using <code>s.replace("\\", "\\\\")</code> IntelliJ does not complain, though, but I need to use the precompiled pattern for performance reasons (100s of MBs of data to process).</p>
  
  <p>Might be a bug as in  <a href="https://stackoverflow.com/questions/42537321/intellij-says-b-backspace-is-an-illegal-escape-sequence-inside-a-string-liter">IntelliJ says \b (backspace) is an illegal escape sequence inside a string literal. Why?</a> ?</p>