title: Grails: Splitting a string that contains a pipe
body: <p>I’m trying to split a <code>String</code>. Simple examples work:</p>
  
  <pre><code>groovy:000&gt; print "abc,def".split(",");
  [abc, def]===&gt; null
  groovy:000&gt;
  </code></pre>
  
  <p>But instead of a comma, I need to split it on pipes, and I’m not getting the desired result:</p>
  
  <pre><code>groovy:000&gt; print "abc|def".split("|");
  [, a, b, c, |, d, e, f]===&gt; null
  groovy:000&gt;
  </code></pre>
  
  <p>So of course my first choice would be to switch from pipes (<code>|</code>) to commas (<code>,</code>) as delimiters. </p>
  
  <p>But now I’m intrigued: Why is this not working? Escaping the pipe (<code>\|</code>) doesn't seem to help:</p>
  
  <pre><code>groovy:000&gt; print "abc|def".split("\|");
  ERROR org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, groovysh_parse: 1: unexpected char: '\' @ line 1, column 24.
     print "abcdef".split("\|");
                            ^
  
  1 error
  |
          at java_lang_Runnable$run.call (Unknown Source)
  groovy:000&gt;
  </code></pre>