title: How can I split a string separated with pipe symbol using jQuery regex
body: <p>I have a dynamically generated string which is basically a row with each value separated by a pipe symbol <code>|</code>, I need to separate it and insert them into a bunch of hidden fields .</p>
  
  <p><a href="https://stackoverflow.com/questions/22555182/splitting-a-string-and-assigning-to-fields">This was almost what I needed to do</a>, but not working for me, and I can only use (<code>~</code> or <code>|</code>) as special characters since my data may contain other characters.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>var data = "Val1@#|val2$%|val3(*|"; // dynamically generated 
  
  $.each(data.split(/\s*|\s+/), function(i, val) {
      alert(val);
  });
  </code></pre>