title: Regular expression ^\\Q & \\E
body: <p>I have below code in my application:</p>
  
  <pre><code>private String getRequestPath(HttpServletRequest req) {
          String path = req.getRequestURI();
          path = path.replaceFirst( "^\\Q" + req.getContextPath() + "\\E", "");
          path = URLDecoder.decode(path);
          System.out.println("req.getRequestURI()="+req.getRequestURI());
          System.out.println("path="+path);
          return path;
      }
  </code></pre>
  
  <p>In the output I can see below messages when I try to access the servlet which this method belongs to:</p>
  
  <pre><code>req.getRequestURI()=/MyApp/test
  path=/test
  </code></pre>
  
  <p>How the <code>^\\Q</code> &amp; <code>\\E</code> works in regular expressions.</p>