title: Groovy: How can I include backslashes inside a string without escaping?
body: <p>I want to use the following string literal inside my groovy program without having to escape the backslashes: </p>
  
  <p><pre>C:\dev\username</pre></p>
  
  <p>Here is what I have tried so far:</p>
  
  <h1>String (Single Quotes) &amp; GStrings (Double Quotes)</h1>
  
  <pre>
  def aString = 'C:\dev\username'
  def aGString = "C:\dev\username"
  </pre>
  
  <ul>
  <li>Doesn't work because \ has special meaning and is used to escape other characters</li>
  <li>I end up having to escape \ with another \  </li>
  </ul>
  
  <pre>def s = 'C:\\dev\\username'</pre>
  
  <h1>Slashy String &amp; Dollar Slashy String</h1>
  
  <p>Works for some strings, like the following</p>
  
  <pre>
  def slashy = /C:\windows\system32/
  def dollarSlashy = $/C:\windows\system32/$</pre> 
  
  <p>But it interprets \u as having special meaning (the following don't work):</p>
  
  <pre>def s1 = /C:\dev\username/
  def s2 = $/C:\dev\username/$</pre>
  
  <ul>
  <li>Groovy:Did not find four digit hex character code</li>
  </ul>