title: How to escape delimiter in data?
body: <p>I have a list of titles that I want to save as a <code>String</code>:<br>
  - <code>title1</code><br>
  - <code>title2</code><br>
  - <code>title|3</code></p>
  
  <p>Now, I want to save this as a single line <code>String</code> delimited by <code>|</code>, which would mean it ends up like this: <code>title1|title2|title|3</code>.</p>
  
  <p>But now, when I split the <code>String</code>:  </p>
  
  <pre><code>String input = "title1|title2|title|3";
  String[] splittedInput = input.split("\\|");
  </code></pre>
  
  <p><code>splittedInput</code> will be the following array: <code>{"title1", "title2", "title", "3"}</code>.</p>
  
  <p>Obviously, this is not what I want, I want the third entry of the array to be <code>title|3</code>. </p>
  
  <p>Now my question: how do I correctly escape the <code>|</code> in the titles so that when I split the <code>String</code> I end up with the correct array of three titles, instead of 4?</p>
  
  <hr>
  
  <p>@Gábor Bakos</p>
  
  <p>Running this code snippet:</p>
  
  <pre><code>String input = "title1|title2|title\\|3";
  String[] split = input.split("(?&lt;!\\\\)\\|");
  
  for (int i = 0; i &lt; split.length; i++) {
      split[i] = split[i].replace("\\\\(?=\\|)", "");
  }
  System.out.println(Arrays.toString(split));
  </code></pre>
  
  <p>I get this output: <code>[title1, title2, title\|3]</code>. What am I doing wrong?</p>